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
[Sql(commandText:"select [Id], [order], [title], [url], [completed] from dbo.ToDo where Id = @Id",
68
-
commandText:System.Data.CommandType.Text,
68
+
commandType:System.Data.CommandType.Text,
69
69
parameters:"@Id={Query.id}",
70
70
connectionStringSetting:"SqlConnectionString")]
71
71
IEnumerable<ToDoItem> toDoItem)
@@ -1081,6 +1081,8 @@ The attribute's constructor takes the SQL command text, the command type, parame
1081
1081
1082
1082
Queries executed by the input binding are [parameterized](/dotnet/api/microsoft.data.sqlclient.sqlparameter) in Microsoft.Data.SqlClient to reduce the risk of [SQL injection](/sql/relational-databases/security/sql-injection) from the parameter values passed into the binding.
1083
1083
1084
+
If an exception occurs when a SQL input binding is executed then the function code will not execute. This may result in an error code being returned, such as an HTTP trigger returning a 500 error code.
The following example shows a [C# function](functions-dotnet-class-library.md) that adds a record to a database, using data provided in an HTTP POST request as a JSON body.
187
+
The following example shows a [C# function](functions-dotnet-class-library.md) that adds a record to a database, using data provided in an HTTP POST request as a JSON body. The return object is the `OutputType` class we created to handle both an HTTP response and the SQL output binding.
179
188
180
189
```cs
181
190
usingSystem;
@@ -195,11 +204,13 @@ namespace AzureSQL.ToDo
195
204
// create a new ToDoItem from body object
196
205
// uses output binding to insert new item into ToDo table
### HTTP trigger, write records using IAsyncCollector
306
-
307
-
The following example shows a [C# function](functions-dotnet-class-library.md) that adds a collection of records to a database, using data provided in an HTTP POST body JSON array.
@@ -1197,7 +1187,10 @@ The following table explains the binding configuration properties that you set i
1197
1187
::: zone pivot="programming-language-csharp,programming-language-javascript,programming-language-powershell,programming-language-python,programming-language-java"
1198
1188
The `CommandText` property is the name of the table where the data is to be stored. The connection string setting name corresponds to the application setting that contains the [connection string](/dotnet/api/microsoft.data.sqlclient.sqlconnection.connectionstring?view=sqlclient-dotnet-core-5.0&preserve-view=true#Microsoft_Data_SqlClient_SqlConnection_ConnectionString) to the Azure SQL or SQL Server instance.
1199
1189
1200
-
The output bindings use the T-SQL [MERGE](/sql/t-sql/statements/merge-transact-sql) statement which requires [SELECT](/sql/t-sql/statements/merge-transact-sql#permissions) permissions on the target database.
1190
+
The output bindings use the T-SQL [MERGE](/sql/t-sql/statements/merge-transact-sql) statement which requires [SELECT](/sql/t-sql/statements/merge-transact-sql#permissions) permissions on the target database.
1191
+
1192
+
If an exception occurs when a SQL output binding is executed then the function code stop executing. This may result in an error code being returned, such as an HTTP trigger returning a 500 error code. If the `IAsyncCollector` is used in a .NET function then the function code can handle exceptions throw by the call to `FlushAsync()`.
0 commit comments