Azure / Azure/azure-functions-sql-extension

Find Alternative to SqlDataAdapter

Open
#4 1 comment 0 reactions 0 assignees View on GitHub
enhancement input-binding
Dominant language
C#
Stars
130
Forks
71
Avg merge
4d 8h
Merged PRs (30d)
4

Description

We currently use `SqlDataAdapter` for both the input binding in the `SqlConverters` [class ](https://github.com/Azure/azure-functions-sql-extension/blob/dev/src/SqlBinding/SqlConverters.cs#L111) and for the output binding in the `SqlAsyncCollector` [class](https://github.com/Azure/azure-functions-sql-extension/blob/dev/src/SqlBinding/SqlAsyncCollector.cs#L103). The reason we do so is because `SqlDataAdapter` supports auto-generation of Insert and Update commands, which is useful for the output binding. We don't have to deal with discovering the table schema, manually generating an upsert command based on what columns are the primary keys, etc., since there is already functionality in place to do that for us. Another advantage is that it is possible to directly serialize/deserialize JSON to/from a DataTable. This makes it easy to convert the JSON string representing the rows the user wants upserted into a format that can then be directly manipulated by internal SQL libraries. Similarly, we can convert the rows we get back from input binding queries into POCOs easily. Otherwise, we would have to find alternative ways to convert between JSON and a SQL row, and then perform the insertion/reading of that row ourselves.

That being said, it doesn't seem like the SQL team is currently doing much to maintain/update the `SqlDataAdapter`, and it doesn't have support yet for asynchronous operations (although the issue is being [tracked)](https://github.com/dotnet/runtime/issues/22109). Ideally, we should move away from `SqlDataAdapter` to something that is more maintained by the SQL team and supports asynchronous operations.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.