分享.NET 轻量级的ORM

分享.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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/109868.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号