GnomeStack.Data
0.1.3
dotnet add package GnomeStack.Data --version 0.1.3
NuGet\Install-Package GnomeStack.Data -Version 0.1.3
<PackageReference Include="GnomeStack.Data" Version="0.1.3" />
paket add GnomeStack.Data --version 0.1.3
#r "nuget: GnomeStack.Data, 0.1.3"
// Install GnomeStack.Data as a Cake Addin #addin nuget:?package=GnomeStack.Data&version=0.1.3 // Install GnomeStack.Data as a Cake Tool #tool nuget:?package=GnomeStack.Data&version=0.1.3
GnomeStack.Data
Provides extension methods for DataRecord and DataReader and includes Dapper and adds additional extension methods for Dapper.
The extensions methods for DataRecord and DataReader are useful for
- Nullable types
- Getting values by name rather than by ordinal.
The extension methods add support Dapper for:
- Retrying database operations using polly which is useful for handling transient errors, especially in Azure.
- Result<T, Exception>` objects rather than throwing exceptions. This is useful for handling errors in a functional way and forcing dealing with Exceptions rather than bubbling them up.
- Extensions that enable ISqlStatementBuilder to be used with Dapper which enables a kind of command object for creating SQL statements and optionally parameters.
Not all cases for for Dapper have been implemented for extension methods. They
will be implemented in time. The Execute, ExecuteScalar, ExecuteReader, and Query<T>
have extension methods.
Usage Examples
Using Result<T, Exception> with Dapper
var r = await connection.ScalarAsResultAsync<int>("SELECT 1");
return r.IsOk ? r.Value : -1;
Using SqlStatementBuilder with Dapper
public class MssqlSelectDbExists : SqlStatementBuilder
{
public MssqlSelectDbExists()
{
}
public MssqlSelectDbExists(string databaseName)
{
this.DatabaseName = databaseName;
}
public string DatabaseName { get; set; } = string.Empty;
public override Result<(string, object?), Exception> Build()
{
if (!MssqlValidate.Identifier(this.DatabaseName.AsSpan()))
return new InvalidDbIdentifierException($"Invalid database name {this.DatabaseName}");
var query = $"""
---noinspection SqlNoDataSourceInspectionForFile
SELECT IIF(COUNT(*) > 0, 1, 0)
FROM sys.databases
WHERE name = '{this.DatabaseName}'
""";
return (query, null);
}
}
// elsewhere
var r = await connection.ScalarAsync<int>(new MssqlSelectDbExists("master"));
if (r == 1)
{
Console.WriteLine("Database exists");
}
else
{
Console.WriteLine("Database does not exist");
}
Using RetryExecuteAsync with Dapper
return await connection.RetryQueryAsync<UserDigest>(
"SELECT name, date FROM users");
MIT License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Dapper (>= 2.0.123)
- GnomeStack.Core (>= 0.1.3)
- Polly (>= 8.0.0)
-
net6.0
- Dapper (>= 2.0.123)
- GnomeStack.Core (>= 0.1.3)
- Polly (>= 8.0.0)
-
net7.0
- Dapper (>= 2.0.123)
- GnomeStack.Core (>= 0.1.3)
- Polly (>= 8.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on GnomeStack.Data:
Package | Downloads |
---|---|
GnomeStack.Data.Mssql
Provides Management Sql statements for Sql Server like creating/dropping databases, users, logins, or getting database sizes, info on resource usage, etc. The library is built on top of GnomeStack.Data which uses dapper and provides extension methods for `IDbConnection` and Dapper that enables classes or structs that implement `ISqlStatementBuilder` to be executed. |
GitHub repositories
This package is not used by any popular GitHub repositories.
# CHANGE LOG
## 0.0.0 initial creation
- created.