Azure / Azure/azure-functions-sql-extension
C# Output Binding Template will rarely work out of the box
- Dominant language
- C#
- Stars
- 130
- Forks
- 71
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 4
Description
Right now we generate a template function like this
```csharp
// Visit https://aka.ms/sqlbindingsoutput to learn how to use this output binding
[FunctionName("SqlOutputBinding")]
public static CreatedResult Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "addtodoitem")] HttpRequest req,
[Sql("", ConnectionStringSetting = "SqlConnectionString")] out ToDoItem output,
ILogger log)
{
log.LogInformation("C# HTTP trigger with SQL Output Binding function processed a request.");
output = new ToDoItem
{
Id = "1",
Priority = 1,
Description = "Hello World"
};
return new CreatedResult($"/api/addtodoitem", output);
}
}
public class ToDoItem
{
public string Id { get; set; }
public int Priority { get; set; }
public string Description { get; set; }
}
```
But it's very likely that this isn't going to work for a user since it relies on them already having a table set up with a schema that matches the `ToDoItem`.
A couple things :
1. For output bindings it would generally be better to have them be for POST requests anyways since they're inserting data into the DB. Unfortunately - unlike the other languages I believe we will need a defined type to use as the object so we can't make this completely generic.
2. We should have comments explaining what fields that user needs to update and what they should be to help with that though
Contributor guide
Assessment
This issue has not been assessed yet.