Skip to content

Commit 7d54b3b

Browse files
authored
Merge pull request snickler#24 from mooshpot/patch-3
Update README.md
2 parents 0bb814a + d384b89 commit 7d54b3b

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,79 @@ Add the `using` statement to pull in the extension method. E.g: `using Snickler.
7171

7272
```
7373

74+
### Using output parameters without returning a result set
75+
76+
```csharp
77+
78+
DbParameter outputParam = null;
79+
80+
var dbContext = GetDbContext();
81+
82+
await dbContext.LoadStoredProc("dbo.SomeSproc")
83+
.WithSqlParam("InputParam1", 1)
84+
.WithSqlParam("myOutputParam", (dbParam) =>
85+
{
86+
dbParam.Direction = System.Data.ParameterDirection.Output;
87+
dbParam.DbType = System.Data.DbType.Int16;
88+
outputParam = dbParam;
89+
})
90+
91+
.ExecuteStoredNonQueryAsync();
92+
93+
int outputParamValue = (short)outputParam.Value;
94+
95+
```
96+
97+
### Using output parameters without returning a result set but also getting the number of rows affected
98+
99+
Make sure your stored procedure does not contain `SET NOCOUNT ON`.
100+
101+
```csharp
102+
int numberOfRowsAffected = -1;
103+
104+
DbParameter outputParam = null;
105+
106+
var dbContext = GetDbContext();
107+
108+
numberOfRowsAffected = await dbContext.LoadStoredProc("dbo.SomeSproc")
109+
.WithSqlParam("InputParam1", 1)
110+
.WithSqlParam("myOutputParam", (dbParam) =>
111+
{
112+
dbParam.Direction = System.Data.ParameterDirection.Output;
113+
dbParam.DbType = System.Data.DbType.Int16;
114+
outputParam = dbParam;
115+
})
116+
117+
.ExecuteStoredNonQueryAsync();
118+
119+
int outputParamValue = (short)outputParam.Value;
120+
121+
```
122+
123+
### Changing the execution timeout when waiting for a stored procedure to return
124+
125+
```csharp
126+
127+
DbParameter outputParam = null;
128+
129+
var dbContext = GetDbContext();
130+
131+
// change timeout from 30 seconds to 300 seconds (5 minutes)
132+
await dbContext.LoadStoredProc("dbo.SomeSproc", commandTimeout:300)
133+
.WithSqlParam("InputParam1", 1)
134+
.WithSqlParam("myOutputParam", (dbParam) =>
135+
{
136+
dbParam.Direction = System.Data.ParameterDirection.Output;
137+
dbParam.DbType = System.Data.DbType.Int16;
138+
outputParam = dbParam;
139+
})
140+
141+
.ExecuteStoredNonQueryAsync();
142+
143+
int outputParamValue = (short)outputParam.Value;
144+
145+
```
146+
147+
148+
149+

0 commit comments

Comments
 (0)