![]() |
VOOZH | about |
dotnet add package Open.Database.Extensions.Channel --version 9.0.3
NuGet\Install-Package Open.Database.Extensions.Channel -Version 9.0.3
<PackageReference Include="Open.Database.Extensions.Channel" Version="9.0.3" />
<PackageVersion Include="Open.Database.Extensions.Channel" Version="9.0.3" />Directory.Packages.props
<PackageReference Include="Open.Database.Extensions.Channel" />Project file
paket add Open.Database.Extensions.Channel --version 9.0.3
#r "nuget: Open.Database.Extensions.Channel, 9.0.3"
#:package Open.Database.Extensions.Channel@9.0.3
#addin nuget:?package=Open.Database.Extensions.Channel&version=9.0.3Install as a Cake Addin
#tool nuget:?package=Open.Database.Extensions.Channel&version=9.0.3Install as a Cake Tool
Useful set of utilities and abstractions for simplifying modern database operations and ensuring dependency injection compatibility.
Connection factories facilitate creation and disposal of connections without the concern of a connection reference or need for awareness of a connection string.
A SqlConnectionFactory is provided and can be overridden to provide more specific dependency injection configurations.
The provided expressive command classes allow for an expressive means to append parameters and execute the results without lengthy complicated setup.
Extensions are provided to create commands from connection factories.
var result = connectionFactory
.StoredProcedure("[procedure name]")
.AddParam("a",1)
.AddParam("b",true)
.AddParam("c","hello")
.ExecuteScalar();
Instead of writing this:
var myResult = new List<T>();
using(var reader = await mySqlCommand.ExecuteReaderAsync(CommandBehavior.CloseConnection))
{
while(await reader.ReadAsync())
myResult.Add(transform(reader));
}
Is now simplified to this:
var myResult = await mySqlCommand.ToListAsync(transform);
In order to keep connection open time to a minimum, some methods cache data before closing the connection and then subsequently applying the transformations as needed.
Results<T>() and ResultsAsync<T>()Queues all the data. Then using the provided type T entity, the data is coerced by which properties intersect with the ones available to the IDataReader.
Optionally a field to column override map can be passed as a parameter. If a column is set as null then that field is ignored (not applied to the model).
If all the columns in the database map exactly to a field: (A column that has no associated field/property is ignored.)
var people = cmd.Results<Person>();
If the database fields don't map exactly:
var people = cmd.Results<Person>(
(Field:"FirstName", Column:"first_name"),
(Field:"LastName", Column:"last_name")));
or
var people = cmd.Results<Person>(
("FirstName", "first_name"),
("LastName", "last_name"));
or
var people = cmd.Results<Person>(new Dictionary<string,string>{
{"FirstName", "first_name"},
{"LastName", "last_name"});
Retrieve() and RetrieveAsync()Queues all the data. Returns a QueryResult<Queue<object[]>> containing the requested data and column information. The .AsDequeueingMappedEnumerable() extension will iteratively convert the results to dictionaries for ease of access.
ResultsAsync<T>ResultsAsync<T>() is fully asynchronous from end-to-end but returns an IEnumerable<T> that although has fully buffered the all the data into memory, has deferred the transformation until enumerated. This way, the asynchronous data pipeline is fully complete before synchronously transforming the data.
Example:
// Returns true if the transaction is successful.
public static bool TryTransaction()
=> ConnectionFactory.Using(connection =>
// Open a connection and start a transaction.
connection.ExecuteTransactionConditional(transaction => {
// First procedure does some updates.
var count = transaction
.StoredProcedure("[Updated Procedure]")
.ExecuteNonQuery();
// Second procedure validates the results.
// If it returns true, then the transaction is committed.
// If it returns false, then the transaction is rolled back.
return transaction
.StoredProcedure("[Validation Procedure]")
.AddParam("@ExpectedCount", count)
.ExecuteScalar<bool>();
}));
.ConfigureAwait(true) are now .ConfigureAwait(false) as they should be. The caller will need to .ConfigureAwait(true) if they need to resume on the calling context.Open.Database.Extensions.MSSqlClient for Microsoft.Data.SqlClient support.| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.0.3 | 3,426 | 3/18/2025 |
| 9.0.3-debug | 230 | 3/18/2025 |
| 9.0.1 | 638 | 3/17/2025 |
| 9.0.1-debug | 226 | 3/17/2025 |
| 9.0.0 | 310 | 3/16/2025 |
| 9.0.0-debug | 198 | 3/16/2025 |
| 8.0.1 | 6,613 | 6/14/2024 |
| 8.0.0 | 3,060 | 1/17/2024 |
| 7.2.0 | 6,477 | 11/9/2022 |
| 7.1.0 | 1,983 | 9/14/2022 |
| 7.0.4 | 934 | 7/7/2022 |
| 7.0.1 | 1,519 | 5/5/2022 |
| 7.0.0 | 1,621 | 2/28/2022 |
| 6.6.2 | 1,591 | 7/16/2020 |