Dapper.Lite 2.0.11

dotnet add package Dapper.Lite --version 2.0.11
NuGet\Install-Package Dapper.Lite -Version 2.0.11
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.Lite" Version="2.0.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dapper.Lite --version 2.0.11
#r "nuget: Dapper.Lite, 2.0.11"
#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.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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.11 268 1/12/2024
2.0.10 117 1/3/2024
2.0.9 109 12/15/2023
2.0.8 203 12/8/2023
2.0.7 139 12/4/2023
2.0.6 201 11/27/2023
2.0.5 103 11/13/2023
2.0.4 133 11/6/2023
2.0.3 105 10/31/2023
2.0.2 102 10/31/2023
2.0.1 117 10/27/2023
2.0.0 108 10/26/2023

更新内容:
           1. IDbSession接口新增返回DataTable的分页查询方法