You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// <param name="commandType">Specifies whether <see cref="CommandText"/> refers to a stored procedure or SQL query string. Defaults to <see cref="CommandType.Text"/></param>
18
+
/// <param name="parameters">Optional - Specifies the parameters that will be used to execute the SQL query or stored procedure. See <see cref="Parameters"/> for more details.</param>
/// Creates an instance of the <see cref="SqlInputAttribute"/>, which takes a SQL query or stored procedure to run and returns the output to the function.
29
+
/// </summary>
30
+
/// <param name="commandText">Either a SQL query or stored procedure that will be run in the target database.</param>
31
+
/// <param name="connectionStringSetting">The name of the app setting where the SQL connection string is stored</param>
Copy file name to clipboardExpand all lines: docs/SetupGuide_Dotnet.md
+13-18Lines changed: 13 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,9 +55,9 @@ See [Input Binding Overview](./BindingsOverview.md#input-binding) for general in
55
55
56
56
The [SqlAttribute](https://github.com/Azure/azure-functions-sql-extension/blob/main/src/SqlAttribute.cs) for Input bindings takes four arguments:
57
57
58
-
- **CommandText**: Passed as a constructor argument to the binding. Represents either a query string or the name of a stored procedure.
59
-
- **ConnectionStringSetting**: Passed as a constructor argument to the binding. Specifies the name of the app setting that contains the SQL connection string used to connect to a database. The connection string must follow the format specified [here](https://docs.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlconnection.connectionstring?view=sqlclient-dotnet-core-2.0).
60
-
- **CommandType**: Specifies whether CommandText is a query (`System.Data.CommandType.Text`) or a stored procedure (`System.Data.CommandType.StoredProcedure`)
58
+
- **CommandText**: Represents either a query string or the name of a stored procedure based on the value of the CommandType.
59
+
- **ConnectionStringSetting**: Specifies the name of the app setting that contains the SQL connection string used to connect to a database. The connection string must follow the format specified [here](https://docs.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlconnection.connectionstring?view=sqlclient-dotnet-core-2.0).
60
+
- **CommandType**: Specifies whether CommandText is a query (`System.Data.CommandType.Text`) or a stored procedure (`System.Data.CommandType.StoredProcedure`). Defaults to `CommandType.Text`.
61
61
- **Parameters**: The parameters to the query/stored procedure. This string must follow the format "@param1=param1,@param2=param2" where @param1 is the name of the parameter and param1 is the parameter value. Each pair of parameter name, parameter value is separated by a comma. Within each pair, the parameter name and value is separated by an equals sign. This means that neither the parameter name nor value can contain "," or "=". To specify a `NULL` parameter value, do"@param1=null,@param2=param2". To specify an empty string as a value, do"@param1=,@param2=param2", i.e. do not put any text after the equals sign of the corresponding parameter name. This argument is auto-resolvable (see Query String examples).
62
62
63
63
The following are valid binding types for the result of the query/stored procedure execution:
@@ -83,8 +83,7 @@ Note: This tutorial requires that a SQL database is setup as shown in [Create a
@@ -225,8 +221,7 @@ public static async Task<IActionResult> Run(
225
221
HttpRequest req,
226
222
[Sql("select * from Products where cost = @Cost",
227
223
"SqlConnectionString",
228
-
CommandType = System.Data.CommandType.Text,
229
-
Parameters = "@Cost={cost}")]
224
+
parameters: "@Cost={cost}")]
230
225
IAsyncEnumerable<Product> products)
231
226
{
232
227
var enumerator = products.GetAsyncEnumerator();
@@ -248,8 +243,8 @@ See [Output Binding Overview](./BindingsOverview.md#output-binding) for general
248
243
249
244
The [SqlAttribute](https://github.com/Azure/azure-functions-sql-extension/blob/main/src/SqlAttribute.cs) for Output bindings takes two arguments:
250
245
251
-
- **CommandText**: Passed as a constructor argument to the binding. Represents the name of the table into which rows will be upserted.
252
-
- **ConnectionStringSetting**: Passed as a constructor argument to the binding. Specifies the name of the app setting that contains the SQL connection string used to connect to a database. The connection string must follow the format specified [here](https://docs.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlconnection.connectionstring?view=sqlclient-dotnet-core-2.0).
246
+
- **CommandText**: Represents the name of the table into which rows will be upserted.
247
+
- **ConnectionStringSetting**: Specifies the name of the app setting that contains the SQL connection string used to connect to a database. The connection string must follow the format specified [here](https://docs.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlconnection.connectionstring?view=sqlclient-dotnet-core-2.0).
253
248
254
249
The following are valid binding types for the rows to be upserted into the table:
255
250
@@ -408,7 +403,7 @@ See [Trigger Binding Overview](./BindingsOverview.md#trigger-binding) for genera
408
403
409
404
The SqlAttribute for Trigger bindings takes two [arguments](https://github.com/Azure/azure-functions-sql-extension/blob/main/src/TriggerBinding/SqlTriggerAttribute.cs)
410
405
411
-
- **TableName**: Passed as a constructor argument to the binding. Represents the name of the table to be monitored for changes.
406
+
- **TableName**: Represents the name of the table to be monitored for changes.
412
407
- **ConnectionStringSetting**: Specifies the name of the app setting that contains the SQL connection string used to connect to a database. The connection string must follow the format specified [here](https://docs.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlconnection.connectionstring?view=sqlclient-dotnet-core-2.0).
413
408
414
409
The trigger binding can bind to type`IReadOnlyList<SqlChange<T>>`:
Copy file name to clipboardExpand all lines: docs/SetupGuide_DotnetOutOfProc.md
+12-17Lines changed: 12 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,10 +66,10 @@ See [Input Binding Overview](./BindingsOverview.md#input-binding) for general in
66
66
67
67
The [SqlInputAttribute](https://github.com/Azure/azure-functions-sql-extension/blob/main/Worker.Extensions.Sql/src/SqlInputAttribute.cs) takes four arguments:
68
68
69
-
- **CommandText**: Passed as a constructor argument to the binding. Represents either a query string or the name of a stored procedure.
70
-
- **CommandType**: Specifies whether CommandText is a query (`System.Data.CommandType.Text`) or a stored procedure (`System.Data.CommandType.StoredProcedure`)
71
-
- **Parameters**: The parameters to the query/stored procedure. This string must follow the format "@param1=param1,@param2=param2" where @param1 is the name of the parameter and param1 is the parameter value. Each pair of parameter name, parameter value is separated by a comma. Within each pair, the parameter name and value is separated by an equals sign. This means that neither the parameter name nor value can contain "," or "=". To specify a `NULL` parameter value, do"@param1=null,@param2=param2". To specify an empty string as a value, do"@param1=,@param2=param2", i.e. do not put any text after the equals sign of the corresponding parameter name. This argument is auto-resolvable (see Query String examples).
69
+
- **CommandText**: Represents either a query string or the name of a stored procedure.
72
70
- **ConnectionStringSetting**: Specifies the name of the app setting that contains the SQL connection string used to connect to a database. The connection string must follow the format specified [here](https://docs.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlconnection.connectionstring?view=sqlclient-dotnet-core-2.0).
71
+
- **CommandType**: Specifies whether CommandText is a query (`System.Data.CommandType.Text`) or a stored procedure (`System.Data.CommandType.StoredProcedure`). Default is `Text`
72
+
- **Parameters**: The parameters to the query/stored procedure. This string must follow the format "@param1=param1,@param2=param2" where @param1 is the name of the parameter and param1 is the parameter value. Each pair of parameter name, parameter value is separated by a comma. Within each pair, the parameter name and value is separated by an equals sign. This means that neither the parameter name nor value can contain "," or "=". To specify a `NULL` parameter value, do"@param1=null,@param2=param2". To specify an empty string as a value, do"@param1=,@param2=param2", i.e. do not put any text after the equals sign of the corresponding parameter name. This argument is auto-resolvable (see Query String examples).
73
73
74
74
The following are valid binding types for the result of the query/stored procedure execution:
75
75
@@ -96,15 +96,14 @@ Note: This tutorial requires that a SQL database is setup as shown in [Create a
*In the above, `select * from Employees` is the SQL script run by the input binding. The CommandType on the line below specifies whether the first line is a query or a stored procedure. On the next line, the ConnectionStringSetting specifies that the app setting that contains the SQL connection string used to connect to the database is "SqlConnectionString." For more information on this, see the [SqlInputAttribute for Input Bindings](#sqlinputattribute-for-input-bindings) section*
106
+
*In the above sample, `select * from Employees` is the SQL script run by the input binding. The CommandType on the line below specifies whether the first line is a query or a stored procedure. On the next line, the ConnectionStringSetting parameter specifies that the app setting that contains the SQL connection string used to connect to the database is "SqlConnectionString." For more information on this, see the [SqlInputAttribute for Input Bindings](#sqlinputattribute-for-input-bindings) section*
108
107
- Add 'using Microsoft.Azure.Functions.Worker.Extensions.Sql;' for using *SqlInput*, the out of proc sql input binding.
109
108
- Add 'using System.Collections.Generic;' to the namespaces list at the top of the page.
110
109
- Currently, there is an error for the IEnumerable. We'll fix this by creating an Employee class.
@@ -143,8 +142,7 @@ The input binding executes the `select * from Products where Cost = @Cost` query
143
142
HttpRequestData req,
144
143
[SqlInput("select * from Products where Cost = @Cost",
145
144
"SqlConnectionString",
146
-
CommandType = System.Data.CommandType.Text,
147
-
Parameters = "@Cost={cost}")]
145
+
parameters: "@Cost={cost}")]
148
146
IEnumerable<Product> products)
149
147
{
150
148
return products;
@@ -182,8 +180,7 @@ In this case, the parameter value of the `@Name` parameter is an empty string.
182
180
HttpRequestData req,
183
181
[SqlInput("select * from Products where Cost = @Cost and Name = @Name",
184
182
"SqlConnectionString",
185
-
CommandType = System.Data.CommandType.Text,
186
-
Parameters = "@Cost={cost},@Name=")]
183
+
parameters: "@Cost={cost},@Name=")]
187
184
IEnumerable<Product> products)
188
185
{
189
186
return products;
@@ -201,8 +198,7 @@ If the `{name}` specified in the `getproducts-namenull/{name}` URL is "null", th
201
198
HttpRequestData req,
202
199
[SqlInput("if @Name is null select * from Products where Name is null else select * from Products where @Name = name",
203
200
"SqlConnectionString",
204
-
CommandType = System.Data.CommandType.Text,
205
-
Parameters = "@Name={name}")]
201
+
parameters: "@Name={name}")]
206
202
IEnumerable<Product> products)
207
203
{
208
204
return products;
@@ -220,8 +216,8 @@ If the `{name}` specified in the `getproducts-namenull/{name}` URL is "null", th
@@ -239,8 +235,7 @@ public static async Task<List<Product>> Run(
239
235
HttpRequestData req,
240
236
[SqlInput("select * from Products where cost = @Cost",
241
237
"SqlConnectionString",
242
-
CommandType = System.Data.CommandType.Text,
243
-
Parameters = "@Cost={cost}")]
238
+
parameters: "@Cost={cost}")]
244
239
IAsyncEnumerable<Product> products)
245
240
{
246
241
var enumerator = products.GetAsyncEnumerator();
@@ -262,7 +257,7 @@ See [Output Binding Overview](./BindingsOverview.md#output-binding) for general
262
257
263
258
The [SqlOutputAttribute](https://github.com/Azure/azure-functions-sql-extension/blob/main/Worker.Extensions.Sql/src/SqlOutputAttribute.cs) takes two arguments:
264
259
265
-
- **CommandText**: Passed as a constructor argument to the binding. Represents the name of the table into which rows will be upserted.
260
+
- **CommandText**: Represents the name of the table into which rows will be upserted.
266
261
- **ConnectionStringSetting**: Specifies the name of the app setting that contains the SQL connection string used to connect to a database. The connection string must follow the format specified [here](https://docs.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlconnection.connectionstring?view=sqlclient-dotnet-core-2.0).
267
262
268
263
The following are valid binding types for the rows to be upserted into the table:
0 commit comments