54 lines
1.4 KiB
Markdown
54 lines
1.4 KiB
Markdown
# Stored Procedures
|
|
|
|
Stored procedure support is available through `db.Procedures` when `DynamicDatabaseOptions.SupportStoredProcedures` is enabled.
|
|
|
|
For an in-depth comparison with query syntax styles and advanced return-shape behavior, see [Syntax Deep Dive and Procedure Calls](syntax-and-procedures-deep-dive.md).
|
|
|
|
## Basic Invocation
|
|
|
|
```csharp
|
|
var scalar = db.Procedures.sp_Exp_Scalar();
|
|
var scalarTyped = db.Procedures.sp_Exp_Scalar<int>();
|
|
```
|
|
|
|
## Input, Output, Return Parameters
|
|
|
|
Prefixes in argument names control parameter direction:
|
|
|
|
- `out_` for output
|
|
- `ret_` for return value
|
|
- `both_` for input/output
|
|
|
|
Example pattern:
|
|
|
|
```csharp
|
|
var res = db.Procedures.sp_Exp_SomeInputAndOutput<
|
|
string,
|
|
MyProcResult>(
|
|
Name: "G4g4r1n",
|
|
out_Result: new DynamicSchemaColumn { Size = 256 },
|
|
ret_Return: 0);
|
|
```
|
|
|
|
## Nested Procedure Names
|
|
|
|
Dynamic member chaining builds qualified names:
|
|
|
|
```csharp
|
|
var res = db.Procedures.dbo.reporting.MyProc();
|
|
```
|
|
|
|
This resolves to `dbo.reporting.MyProc`.
|
|
|
|
## Result Mapping
|
|
|
|
If generic return types are provided, DynamORM attempts mapper-based projection into the target type.
|
|
|
|
If output parameters are present, result payload is assembled from:
|
|
|
|
- main scalar/resultset-derived value
|
|
- output values
|
|
- optional return value
|
|
|
|
The behavior is implemented in `DynamORM/DynamicProcedureInvoker.cs` and documented in XML examples in `DynamORM/DynamicDatabase.cs`.
|