Dapper.Extensions.Expression 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Dapper.Extensions.Expression --version 1.1.0                
NuGet\Install-Package Dapper.Extensions.Expression -Version 1.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.Extensions.Expression" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dapper.Extensions.Expression --version 1.1.0                
#r "nuget: Dapper.Extensions.Expression, 1.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.Extensions.Expression as a Cake Addin
#addin nuget:?package=Dapper.Extensions.Expression&version=1.1.0

// Install Dapper.Extensions.Expression as a Cake Tool
#tool nuget:?package=Dapper.Extensions.Expression&version=1.1.0                

Dapper.Extensions.Expression

Dapper.Extensions.Expression is a lightweight Object/Relational Mapping(ORM) library. The query interface is similar to LINQ. You can query data like LINQ and do any things(Join Query | Group Query | Aggregate Query | Insert | Batch Update | Batch Delete) by lambda with Dapper.Extensions.Expression.

NuGet Install Command

Database Install Command
Dapper.Extensions.Expression Install-Package Dapper.Extensions.Expression

License

MIT License

Usage

  • Entity
public class QueryParam
{
    public DateTime? CreateTime { get; set; }

    public bool? IsDelete { get; set; }

    public string Key { get; set; }
}


[Table("buyer")]
public class Buyer : IEntity
{
    [Key] public Guid Id { get; set; }

    public string Name { get; set; }

    public BuyerType Type { get; set; }

    public string Code { get; set; }

    public string Identity { get; set; }

    public string Email { get; set; }

    public string Mobile { get; set; }

    public bool IsDelete { get; set; }

    public bool? IsActive { get; set; }

    public DateTime CreateTime { get; set; }

    public DateTime? UpdateTime { get; set; }

    public int Version { get; set; }
}

[Table("items")]
public class Item : IEntity
{
    [Key]
    public Guid Id { get; set; }

    public Guid OrderId { get; set; }

    public int Index { get; set; }

    public string Code { get; set; }

    public string Name { get; set; }

    public decimal Price { get; set; }

    public decimal Quantity { get; set; }

    public decimal? Discount { get; set; }

    public decimal Amount { get; set; }

    public string Unit { get; set; }

    public int Version { get; set; }
}

[Table("order")]
public class Order : IEntity
{
    [Key] public Guid Id { get; set; }

    public Guid BuyerId { get; set; }

    [Column("Number")]
    public string SerialNo { get; set; }

    public string Remark { get; set; }

    public Status Status { get; set; }

    public SignState? SignState { get; set; }

    public decimal Amount { get; set; }
    public decimal? Freight { get; set; }

    public Guid? DocId { get; set; }

    public bool IsDelete { get; set; }

    public bool? IsActive { get; set; }

    public bool IsEnable { get; set; }

    public DateTime CreateTime { get; set; }

    public DateTime? UpdateTime { get; set; }

    [Computed]
    public int Index { get; set; }

    [NotMapped]
    public LogType Type { get; set; }

    [NotMapped]
    public string Ignore { get; set; }

    public int Version { get; set; }
}

public interface IEntity
{
    Guid Id { get; set; }

    int Version { get; set; }
}

public enum LogType
{
    Log,
    Trace
}

public enum Status
{
    Draft,
    Running,
    Stop
}

public enum SignState
{
    UnSign,
    Signed
}

public enum BuyerType
{
    Person,
    Company,
    Other
}
  • Query
IDbConnection connection = new MsSqlConnection("ConnectionString");
Query<Order> query = connection.Query<Order>();
  • Query
using IDbConnection connection = new MsSqlConnection("ConnectionString");
Query<Order> query = connection.Query<Order>();
query.Where(v => v.Remark.Contains("FD2"));
List<Order> data = query.ToList<Order>();
  • Join Query
using IDbConnection connection = new MsSqlConnection("ConnectionString");
JoinQuery<Order, Item> query = connection.JoinQuery<Order, Item>().On(JoinType.Left, (a, b) => a.Id == b.OrderId);
query.Where((v, w) => v.SerialNo.Contains("FD2"));
IEnumerable<Order> data = query.ToList<Order>();
  • Group Query
using IDbConnection connection = new MsSqlConnection("ConnectionString");
JoinQuery<Order, Item> query = connection.JoinQuery<Order, Item>().On(JoinType.Left, (a, b) => a.Id == b.OrderId);
List<Order> result = await query.Select((a, b) => new { a.CreateTime, Total = Function.Count() }).GroupBy((f, g) => f.CreateTime).Having((f, d) => f.CreateTime > new DateTime(2021, 3, 10)).ToListAsync<Order>();
  • Insert
IDbConnection connection = new MsSqlConnection("ConnectionString");
Buyer buyer = CreateBuyer();
connection.Insert(buyer)
  • Update
IDbConnection connection = new MsSqlConnection("ConnectionString");
 Order order = connection.Get<Order>(f => f.Id == new Guid("000c70b3-fccc-4838-a524-9b7edc4f9c9a"));
 order.UpdateTime = DateTime.Now;
 order.Amount = Convert.ToDecimal(new Random().NextDouble() * 100);
 int updated = connection.Update(order);
  • Delete
IDbConnection connection = new MsSqlConnection("ConnectionString");
connection.Delete<Order>(x => x.IsDelete)
Product 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 was computed.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.2 120 8/24/2024
1.1.0 130 8/10/2024
1.0.10 69 7/30/2024
1.0.9 210 8/11/2023
1.0.8 176 8/11/2023
1.0.0.7 307 12/29/2021
1.0.0.6 312 12/28/2021
1.0.0.5 361 7/7/2021
1.0.0.4 379 4/9/2021
1.0.0.3 320 4/8/2021
1.0.0.2 408 4/8/2021
1.0.0.1 351 3/15/2021

support sql server