Dapper.Lite
3.0.1
dotnet add package Dapper.Lite --version 3.0.1
NuGet\Install-Package Dapper.Lite -Version 3.0.1
<PackageReference Include="Dapper.Lite" Version="3.0.1" />
<PackageVersion Include="Dapper.Lite" Version="3.0.1" />
<PackageReference Include="Dapper.Lite" />
paket add Dapper.Lite --version 3.0.1
#r "nuget: Dapper.Lite, 3.0.1"
#:package Dapper.Lite@3.0.1
#addin nuget:?package=Dapper.Lite&version=3.0.1
#tool nuget:?package=Dapper.Lite&version=3.0.1
一款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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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.35)
- System.ComponentModel.Annotations (>= 4.7.0)
-
.NETStandard 2.0
- Dapper (>= 2.1.35)
- System.ComponentModel.Annotations (>= 4.7.0)
-
net6.0
- Dapper (>= 2.1.35)
- 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.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.1 | 150 | 1/7/2026 |
| 3.0.0 | 786 | 7/22/2025 |
| 2.0.13 | 2,812 | 8/30/2024 |
| 2.0.12 | 232 | 7/22/2024 |
| 2.0.11 | 572 | 1/12/2024 |
| 2.0.10 | 264 | 1/3/2024 |
| 2.0.9 | 247 | 12/15/2023 |
| 2.0.8 | 424 | 12/8/2023 |
| 2.0.7 | 242 | 12/4/2023 |
| 2.0.6 | 462 | 11/27/2023 |
| 2.0.5 | 205 | 11/13/2023 |
| 2.0.4 | 257 | 11/6/2023 |
| 2.0.3 | 205 | 10/31/2023 |
| 2.0.2 | 205 | 10/31/2023 |
| 2.0.1 | 228 | 10/27/2023 |
| 2.0.0 | 225 | 10/26/2023 |
更新内容:
1. 修复QueryByIdAsync查询BUG