Dapper.Client
3.1.0
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.6.1
This package targets .NET Framework 4.6.1. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Dapper.Client --version 3.1.0
NuGet\Install-Package Dapper.Client -Version 3.1.0
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.Client" Version="3.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dapper.Client --version 3.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Dapper.Client, 3.1.0"
#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.Client as a Cake Addin #addin nuget:?package=Dapper.Client&version=3.1.0 // Install Dapper.Client as a Cake Tool #tool nuget:?package=Dapper.Client&version=3.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Dapper.Client
基于Dapper的快速访问客户端(mssql,mysql,oracle)
使用方式
// 使用工厂方法拿到 dbclient,可直接实现一个单例使用。
var dbClient1 = DbClientFactory.CreateDbClient(DbClientType.SqlServer, "connectionString", null, null);
// 或者 直接手动实例化 拿到 dbclient,可直接实现一个单例使用。
IDbClient dbClient2 = new SqlClient("connectionString")
{
DefaultReadTimeout = null,
DefaultWriteTimeout = null
}
/*
拿到client之后,client提供了对Dapper接口的封装,
方法签名基本一致,只有两个地方有区别
1. 方法签名中的 IDbTransaction 参数被移除了,使用封装的ITransactionKeeper进行操作, 稍后介绍。
2. 方法签名中的 commandTimeout 参数如果为null时,根据操作的性质(写入|读取)使用client的默认超时时间。
3. 因为1、2点 所以方法签名中的CommandDefinition 变更为 SlimCommandDefinition。
*/
_dbClient1.Query<string>("sql");
/*
事务的使用方式:
通过client.CreateTransaction()方法获取到ITransactionKeeper,
其中ITransactionKeeper:IDbClient 所以也提供一样的方法可直接调用。
注意点:
1. using 之前如果没有 Commit|Rollback,将自动Rollback
2. 当tran 再次调用CreateTransaction 时,还是返回原来的 tran,
但是嵌套层级+1,只能由最外层(嵌套层级为0的)的tran来Commit|Rollback
3. 基于第二点,建议使用函数式的变成方式来编写事务相关的方法,
根据方法的业务传入ITransactionKeeper|IDbclient的参数。
*/
using (var tran = _dbClientl.CreateTransaction())
{
tran.Query<int?>("sql");
tran.Commit();
}
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 | 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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.6.1
- Dapper (>= 2.0.30)
- MySql.Data (>= 8.0.17)
- Oracle.ManagedDataAccess (>= 19.3.1)
-
.NETStandard 2.0
- Dapper (>= 2.0.30)
- Microsoft.Data.SqlClient (>= 1.0.19269.1)
- MySql.Data (>= 8.0.17)
- Oracle.ManagedDataAccess.Core (>= 2.19.31)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.