Dapper.Extensions.Expression
1.1.2
dotnet add package Dapper.Extensions.Expression --version 1.1.2
NuGet\Install-Package Dapper.Extensions.Expression -Version 1.1.2
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.2" />
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.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Dapper.Extensions.Expression, 1.1.2"
#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.2 // Install Dapper.Extensions.Expression as a Cake Tool #tool nuget:?package=Dapper.Extensions.Expression&version=1.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | 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 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.
-
.NETStandard 2.0
- Dapper (>= 2.1.35)
- Microsoft.CSharp (>= 4.7.0)
- System.Reflection.Emit (>= 4.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
bug fixed