Dapper.Lite
2.0.11
dotnet add package Dapper.Lite --version 2.0.11
NuGet\Install-Package Dapper.Lite -Version 2.0.11
<PackageReference Include="Dapper.Lite" Version="2.0.11" />
paket add Dapper.Lite --version 2.0.11
#r "nuget: Dapper.Lite, 2.0.11"
// Install Dapper.Lite as a Cake Addin
#addin nuget:?package=Dapper.Lite&version=2.0.11
// Install Dapper.Lite as a Cake Tool
#tool nuget:?package=Dapper.Lite&version=2.0.11
一款Dapper扩展,单表查询和SQL拼接查询条件支持Lambda表达式。支持Oracle、MSSQL、MySQL、PostgreSQL、SQLite、Access、ClickHouse等数据库。 另外只要ADO.NET支持的数据库,都可以很方便地通过实现IProvider接口支持,仅需写150行左右的代码。
文档: https://github.com/0611163/Dapper.Lite/blob/main/README.md
QQ群: 如有疑问可以加QQ群:497956447
经典示例:
var session = DapperLiteFactory.GetSession();
List<BsOrder> list = session
.Sql<BsOrder>(@"
select o.*, u.user_name as OrderUserName, u.real_name as OrderUserRealName
from bs_order o
left join sys_user u on u.id=o.order_userid")
.Where(o => o.Status == 0
&& o.Remark.Contains("订单")
&& o.OrderTime >= new DateTime(2010, 1, 1)
&& o.OrderTime < DateTime.Now.Date.AddDays(1))
.Where<SysUser>(u => new long[] { 8, 9, 10 }.Contains(u.Id))
.Append("order by o.order_time desc, o.id asc")
.ToList();
经典示例2:
DateTime? startTime = null;
var session = DapperLiteFactory.GetSession();
session.OnExecuting = (s, p) => Console.WriteLine(s); //打印SQL
List<SysUser> list = session.Sql(@"
select * from sys_user t where t.id <= @Id", new { Id = 20 })
.Append(@" and t.create_userid = @CreateUserId
and t.password like @Password
and t.id in @Ids",
new
{
CreateUserId = "1",
Password = "%345%",
Ids = session.ForList(new List<int> { 1, 2, 9, 10, 11 })
})
.AppendIf(startTime.HasValue, " and t.create_time >= @StartTime ", new { StartTime = startTime })
.Append(" and t.create_time <= @EndTime ", new { EndTime = new DateTime(2022, 8, 1) })
.QueryList<SysUser>();
long id = session.Sql("select id from sys_user where id=@Id", new { Id = 1 })
.QuerySingle<long>();
Assert.IsTrue(id == 1);
foreach (SysUser item in list)
{
Console.WriteLine(ModelToStringUtil.ToString(item));
}
Assert.IsTrue(list.Count > 0);
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 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. |
-
.NETFramework 4.6.1
- Dapper (>= 2.1.24)
- System.ComponentModel.Annotations (>= 4.7.0)
-
.NETStandard 2.0
- Dapper (>= 2.1.24)
- System.ComponentModel.Annotations (>= 4.7.0)
-
net6.0
- Dapper (>= 2.1.24)
- System.ComponentModel.Annotations (>= 4.7.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Dapper.Lite:
Package | Downloads |
---|---|
Dapper.Lite.Provider.ClickHouse
Dapper.Lite的数据库实现,基于ClickHouse.Client。您也可以自己实现IProvider接口。 |
|
Dapper.Lite.Provider.SQLite
Dapper.Lite的数据库实现。您也可以自己实现IProvider接口。注意:您需要额外引用System.Data.SQLite.dll或其它dll。 |
|
Dapper.Lite.Provider.Access
Dapper.Lite的数据库实现。您也可以自己实现IProvider接口。 |
|
Lite.Dapper.Provider.MySQL
Dapper.Lite的数据库实现。您也可以自己实现IProvider接口。 |
|
Lite.Dapper.Provider.Oracle
Dapper.Lite的数据库实现。您也可以自己实现IProvider接口。 |
GitHub repositories
This package is not used by any popular GitHub repositories.
更新内容:
1. IDbSession接口新增返回DataTable的分页查询方法