Dapper.SqlGenerator.Async
1.1.3
dotnet add package Dapper.SqlGenerator.Async --version 1.1.3
NuGet\Install-Package Dapper.SqlGenerator.Async -Version 1.1.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dapper.SqlGenerator.Async" Version="1.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dapper.SqlGenerator.Async --version 1.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Dapper.SqlGenerator.Async, 1.1.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Dapper.SqlGenerator.Async as a Cake Addin
#addin nuget:?package=Dapper.SqlGenerator.Async&version=1.1.3
// Install Dapper.SqlGenerator.Async as a Cake Tool
#tool nuget:?package=Dapper.SqlGenerator.Async&version=1.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Dapper.SqlGenerator
Database agnostic SQL code generation for Dapper without POCO attributes and Entity Framework Core compatible schema definition.
Dapper.SqlGenerator.Async
Dapper database agnostic async SELECT, INSERT, UPDATE, DELETE, MERGE queries and a file or resource database migration tool
Dapper.SqlGenerator Quick Start
Create model from db:
dotnet ef dbcontext scaffold "Server=.\SQLEXPRESS;Database=MyDb;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -o Models
Use the model above:
OnModelCreating(DapperSqlGenerator.Configure());
Available functions:
using Dapper.SqlGenerator;
string insertSql = connection.Sql().Insert<Product>();
string insertAndReturnSql = connection.Sql().InsertReturn<Product>();
string updateSql = connection.Sql().Update<Product>();
string deleteSql = connection.Sql().Delete<Product>();
string tableName = connection.Sql().Table<Order>();
string commaSeparatedNonKeyColumns = connection.Sql().GetColumns<Order>(ColumnSelection.NonKeys | ColumnSelection.Computed);
string keysAtQueryParams = connection.Sql().GetParams<Order>(ColumnSelection.Keys);
string columnEqualParams = connection.Sql().GetColumnEqualParams<Order>(ColumnSelection.NonKeys);
connection.Sql().HasColumnSet("unique_order", x => x.OrderId, x => x.ProductId);
string upsertMergeSql = connection.Sql().Merge<Order>("unique_order");
Dapper.SqlGenerator.Async Quick Start
SELECT and CRUD:
using Dapper.SqlGenerator;
using Dapper.SqlGenerator.Async;
connection.Sql().HasColumnSet<Product>("id+kind+content", x => x.Id, x => x.Kind, x => x.Content);
var all = await connection.SelectAsync<Product>();
var allWithSomeColumns = await connection.SelectAsync<Product>("id+kind+content");
var filtered = await connection.SelectWhereAsync<Product>("WHERE Kind > 5");
var firstWithSomeColumns = await connection.SelectFirstAsync<Product>(new { Id = 1 }, "id+kind+content");
var fisrtOrNull = connection.SelectFirstOrDefaultAsync<Product>(new { Id = -1 });
var single = = await connection.SelectSingleAsync<Product>(new { Id = 1 });
var singleOrNull = = await connection.SelectSingleOrDefaultAsync<Product>(new { Id = 1 });
var rows1 = await connection.InsertAsync(new Product { Kind = 4, Content = "Square" });
var inserted1 = await connection.InsertReturnAsync(new Product { Kind = 7, Content = "Triangle" });
var rows2 = await connection.UpdateAsync(new Product { Id = 1, Kind = 66, Content = "Modified" });
var deleted = await connection.DeleteAsync(new Product { Id = 2 });
connection.Sql().HasColumnSet<Product>("content", x => x.Content);
var insertedOrUpdated = await connection.MergeAsync(new Product { Kind = 7, Content = "Triangle", Value = 123 }, "content", "id+kind+content");
Database migration from scripts embedded as resources in MigrationResources namespace, for Sqlite:
using Dapper.SqlGenerator.Async.Migration;
var connectionString = "Data Source=:memory:";
await using var connection = new SQLiteConnection(connectionString);
connection.Open();
var namespaceName = Assembly.GetExecutingAssembly().GetName().Name + ".MigrationResources";
var noMigrationsApplied = await connection.InitDatabase(Assembly.GetExecutingAssembly(), namespaceName);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Dapper (>= 2.0.35)
- Dapper.SqlGenerator (>= 1.1.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.