Implement SqlDataSource
- Dominant language
- C#
- Stars
- 989
- Forks
- 340
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 72
Description
.NET 7.0 introduced the new DbDataSource abstraction to System.Data ([issue](https://github.com/dotnet/runtime/issues/64812)), [here's a video](https://www.youtube.com/watch?v=vRUtHeUpU44&list=PLdo4fOcmZ0oX-DBuRG4u58ZTAJgBAeQ-t&index=71) discussing it in depth.
Now, the .NET 7.0 implementation provides a default implementation which can be obtained from the ADO.NET provider's DbProviderFactory without the driver needing to implement anything. So the following code already works today:
```c#
await using var dataSource = SqlClientFactory.Instance.CreateDataSource("");
await using var connection = await dataSource.OpenConnectionAsync();
await using var command = connection.CreateCommand();
command.CommandText = "SELECT 1";
Console.WriteLine(command.ExecuteScalar());
```
However, this provides a database-agnostic DbDataSource which isn't typed to any specific provider, so it hands out DbConnections rather than SqlConnections, which may be cumbersome to work with if the user is only targeting SQL Server.
A proper SqlDataSource implementation in SqlClient would solve this, and also provide a good configuration/setup point (e.g. for authentication/access tokens, rather than the current static methods).
Contributor guide
Assessment
This issue has not been assessed yet.