Fork me on GitHub

分享.NET 轻量级的ORM

ORM

https://github.com/StackExchange/dapper-dot-net
http://fluentdata.codeplex.com/
https://github.com/toptensoftware/PetaPoco
https://github.com/schotime/NPoco
https://github.com/ServiceStack/ServiceStack.OrmLite

使用Dapper

1.已经在项目中使用了Dapper,感觉还行,基本可以满足需求
2.使用Dapper一段时间,AnsiStringFixedLength 与AnsiString区别 
http://stackoverflow.com/search?page=1&tab=votes&q=dapper
3.扩展Dapper :
https://github.com/tmsmith/Dapper-Extensions or Dapper.Rainbow VS Dapper.Contrib

影响执行计划

Ansi Strings and varchar

Dapper supports varchar params, if you are executing a where clause on a varchar column using a param be sure to pass it in this way:

Query<Thing>("select * from Thing where Name = @Name", new {Name = new DbString { Value = "abcde", IsFixedLength = true, Length = 10, IsAnsi = true });

List Support

Dapper allow you to pass in IEnumerable and will automatically parameterize your query.

For example:

connection.Query<int>("select * from (select 1 as Id union all select 2 union all select 3) as X where Id in @Ids", new { Ids = new int[] { 1, 2, 3 });

Will be translated to:

select * from (select 1 as Id union all select 2 union all select 3) as X where Id in (@Ids1, @Ids2, @Ids3)" // @Ids1 = 1 , @Ids2 = 2 , @Ids2 = 3
_db.Query<Users>("SELECT * FROM dbo.Users  WHERE id IN @ids ",new { ids = IDs.ToArray()}).ToList();

Refer:
Dapper.Rainbow VS Dapper.Contrib
http://stackoverflow.com/questions/10030285/dapper-rainbow-vs-dapper-contrib
Using Dapper QueryMultiple in Oracle
http://stackoverflow.com/questions/18772781/using-dapper-querymultiple-in-oracle
SELECT * FROM X WHERE id IN (…) with Dapper ORM
http://stackoverflow.com/questions/8388093/select-from-x-where-id-in-with-dapper-orm
扩展Dapper
https://github.com/tmsmith/Dapper-Extensions
Any Question
http://stackoverflow.com/search?page=1&tab=votes&q=dapper

posted @   花儿笑弯了腰  阅读(1152)  评论(1编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述
点击右上角即可分享
微信分享提示