LiteOrm.Common 8.0.16

dotnet add package LiteOrm.Common --version 8.0.16
                    
NuGet\Install-Package LiteOrm.Common -Version 8.0.16
                    
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="LiteOrm.Common" Version="8.0.16" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LiteOrm.Common" Version="8.0.16" />
                    
Directory.Packages.props
<PackageReference Include="LiteOrm.Common" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LiteOrm.Common --version 8.0.16
                    
#r "nuget: LiteOrm.Common, 8.0.16"
                    
#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.
#:package LiteOrm.Common@8.0.16
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LiteOrm.Common&version=8.0.16
                    
Install as a Cake Addin
#tool nuget:?package=LiteOrm.Common&version=8.0.16
                    
Install as a Cake Tool

LiteOrm

License GitHub


📖 English Version

A lightweight, high-performance .NET ORM framework that combines micro-ORM speed with full-ORM ergonomics. It is a strong fit for projects that need predictable performance and flexible SQL composition.

Table of Contents

🎯 Core Features

  • Ultra-Fast Performance: Performance close to native Dapper, far exceeding EF Core

  • Multi-Database Support: Native support for SQL Server, MySQL, Oracle, PostgreSQL, SQLite

  • Flexible Querying: Multiple query methods via Lambda, Expr, or ExprString

  • Automatic Associations: Implement JOIN queries via attributes without manual SQL writing

  • Declarative Transactions: AOP transaction management via [Transaction] attribute

  • Dynamic Sharding: Table routing via IArged interface

  • Async Support: Complete async/await support

  • Type Safety: Strong-typed generic interfaces with compile-time type checking

📋 Requirements

  • .NET 8.0+ or .NET Standard 2.0 (.NET Framework 4.6.1+)

  • Dependencies: Autofac, Castle.Core

📦 Installation


dotnet add package LiteOrm


🚀 Quick Start

1. Configure Connection

In appsettings.json:


{

    "LiteOrm": {

        "Default": "DefaultConnection",

        "DataSources": [

            {

                "Name": "DefaultConnection",

                "ConnectionString": "Server=localhost;Database=TestDb;...",

                "Provider": "MySqlConnector.MySqlConnection, MySqlConnector"

            }

        ]

    }

}

In Program.cs:

Console:


var host = Host.CreateDefaultBuilder(args)

    .RegisterLiteOrm()

    .Build();

ASP.NET Core:


var builder = WebApplication.CreateBuilder(args);

builder.Host.RegisterLiteOrm();

2. Define Entity


using LiteOrm.Common;



[Table("Users")]

public class User

{

    [Column("Id", IsPrimaryKey = true, IsIdentity = true)]

    public int Id { get; set; }



    [Column("UserName")]

    public string UserName { get; set; }



    [Column("Email")]

    public string Email { get; set; }



    [Column("CreateTime")]

    public DateTime? CreateTime { get; set; }

}

3. Define a service (optional)


public interface IUserService :

    IEntityService<User>, IEntityServiceAsync<User>

{

}



public class UserService : EntityService<User>, IUserService

{

}

4. Use the service


// Insert

var user = new User { UserName = "admin", Email = "admin@test.com" };

await userService.InsertAsync(user);



// Query

var users = await userService.SearchAsync(u => u.Email.Contains("test"));



// Update

user.Email = "newemail@test.com";

await userService.UpdateAsync(user);



// Delete

await userService.DeleteAsync(user);



// Pagination

var page = await userService.SearchAsync(

    q => q.Where(u => u.CreateTime > DateTime.Today)

          .OrderByDescending(u => u.CreateTime)

          .Skip(0).Take(10)

);

💡 Key Features

Lambda Queries


var users = await userService.SearchAsync(u => u.Age > 18);

Best for most day-to-day queries where readability and compile-time checking matter most.

Expr queries

using static LiteOrm.Common.Expr;

var expr = Prop("Age") > 18 & Prop("Status") == 1;

var users = await userService.SearchAsync(expr);

Best for dynamically assembled filters, admin search screens, and query-builder style scenarios.

ExprString queries (.NET 8.0+)

using static LiteOrm.Common.Expr;

int minAge = 18;

var expr = Prop("Age") > 25;

var users = await objectViewDAO.Search(

    $"WHERE {expr} AND Age > {minAge}"

).ToListAsync();

var dataTable = await dataViewDAO.Search(

    $"SELECT Id, UserName FROM Users WHERE {Prop("Age")} > {minAge}",

    isFull: true

).GetResultAsync();

Use this as the DAO-side SQL entry when Lambda or pure Expr is not enough. It can represent either a Search condition fragment or a full SQL statement. Service query APIs do not expose ExprString.

Automatic associations


[Table("Orders")]

public class Order

{

    [Column("Id", IsPrimaryKey = true)]

    public int Id { get; set; }



    [Column("UserId")]

    [ForeignType(typeof(User))]

    public int UserId { get; set; }

}



public class OrderView : Order

{

    [ForeignColumn(typeof(User), Property = "UserName")]

    public string UserName { get; set; }

}



var orders = await orderService.SearchAsync<OrderView>();

Declarative transactions


[Transaction]

public async Task CreateUserWithOrder(User user, Order order)

{

    await userService.InsertAsync(user);

    order.UserId = user.Id;

    await orderService.InsertAsync(order);

}

Dynamic sharding


public class Log : IArged

{

    [Column("Id", IsPrimaryKey = true)]

    public int Id { get; set; }



    [Column("CreateTime")]

    public DateTime CreateTime { get; set; }



    string[] IArged.TableArgs => [CreateTime.ToString("yyyyMM")];

}

查询时可通过 tableArgsWithArgs(...)Expr.From<T>(...) 显式指定分表参数;主表指定的 TableArgs 会传递给同作用域或下级作用域中的后续表,未显式指定时会继续沿用这组参数。若表名包含多个占位符(如 Sales_{0}_{1}),也可以分别传入 ["US", "2025"] 这样的多维参数,避免手工拼接分表名。不同表还可以错开使用不同占位符位置,例如 Table1_{0}Table2_{1} 可共享同一个参数数组,让一组 TableArgs 同时驱动多张表。

📚 Documentation & Resources

Start with the docs hub, then follow the section that matches your scenario.

🤝 Contributing

Found a bug? Have a suggestion? Please open an Issue or Pull Request.

📄 License

MIT License

Back to top


📖 中文版本

LiteOrm 是一个轻量级、高性能的 .NET ORM 框架,兼顾微型 ORM 的执行效率和完整 ORM 的易用性,适合对性能敏感且需要灵活处理复杂 SQL 的场景。

目录

🎯 核心特性

  • 极速性能:性能接近原生 Dapper,远超 EF Core

  • 多数据库支持:原生支持 SQL Server、MySQL、Oracle、PostgreSQL、SQLite

  • 灵活查询:支持基于 Lambda、ExprExprString 的多种查询方式

  • 自动关联:通过特性实现无损的 JOIN 查询,无需手写 SQL

  • 声明式事务[Transaction] 特性实现 AOP 事务管理

  • 动态分表IArged 接口支持分表路由

  • 异步支持:完整的 async/await 支持

  • 类型安全:强类型泛型接口,编译时类型检查

📋 环境要求

  • .NET 8.0+.NET Standard 2.0(兼容 .NET Framework 4.6.1+)

  • 依赖库:Autofac、Castle.Core

📦 安装


dotnet add package LiteOrm


🚀 快速入门

1. 配置连接

appsettings.json:


{

    "LiteOrm": {

        "Default": "DefaultConnection",

        "DataSources": [

            {

                "Name": "DefaultConnection",

                "ConnectionString": "Server=localhost;Database=TestDb;...",

                "Provider": "MySqlConnector.MySqlConnection, MySqlConnector"

            }

        ]

    }

}

Program.cs:

控制台应用:


var host = Host.CreateDefaultBuilder(args)

    .RegisterLiteOrm()

    .Build();

ASP.NET Core 应用:


var builder = WebApplication.CreateBuilder(args);

builder.Host.RegisterLiteOrm();

2. 定义实体

using LiteOrm.Common;



[Table("Users")]

public class User

{

    [Column("Id", IsPrimaryKey = true, IsIdentity = true)]

    public int Id { get; set; }



    [Column("UserName")]

    public string UserName { get; set; }



    [Column("Email")]

    public string Email { get; set; }



    [Column("CreateTime")]

    public DateTime? CreateTime { get; set; }

}

3. 定义服务(可选)

public interface IUserService :

    IEntityService<User>, IEntityServiceAsync<User>

{

}



public class UserService : EntityService<User>, IUserService

{

}

4. 使用服务

// 插入

var user = new User { UserName = "admin", Email = "admin@test.com" };

await userService.InsertAsync(user);



// 查询

var users = await userService.SearchAsync(u => u.Email.Contains("test"));



// 更新

user.Email = "newemail@test.com";

await userService.UpdateAsync(user);



// 删除

await userService.DeleteAsync(user);



// 分页

var page = await userService.SearchAsync(

    q => q.Where(u => u.CreateTime > DateTime.Today)

          .OrderByDescending(u => u.CreateTime)

          .Skip(0).Take(10)

);

💡 常见特性

  • Lambda 查询:默认优先的查询方式,适合大多数日常业务筛选

  • Expr 表达式:适合后台筛选、查询构造器等动态条件拼装场景

  • ExprString 查询:仅在 DAO 层使用,可传 Search 条件片段或完整 SQL

  • Lambda 与 Expr 组合:在保留强类型可读性的同时复用动态条件

  • 自动关联:无损的 JOIN 查询

  • 声明式事务:基于特性的 AOP 事务

  • 动态分表:自动分表路由

📚 文档与资源

建议先从文档中心进入,再按“入门篇 / 核心使用篇 / 高级特性篇 / 扩展开发篇”的路径继续阅读。

🤝 贡献与反馈

欢迎提交 IssuePull Request

📄 开源协议

MIT 协议

回到顶部

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 is compatible.  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 is compatible.  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 is compatible. 
.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 (1)

Showing the top 1 NuGet packages that depend on LiteOrm.Common:

Package Downloads
LiteOrm

LiteOrm 是一个轻量级、高性能的 .NET ORM (对象关系映射) 框架。

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.0.16 96 5/27/2026
8.0.15 106 5/9/2026
8.0.14 107 4/28/2026
8.0.13 113 4/11/2026
8.0.12 108 4/2/2026
8.0.11 102 3/20/2026
8.0.10 125 3/16/2026
8.0.9 103 3/10/2026
8.0.8 99 3/7/2026
8.0.7 100 3/5/2026
8.0.6 112 2/9/2026
8.0.5 114 1/29/2026