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

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

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

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 【错误记录】FFmpeg 推流报错 ( FLV does not support sample rate 8000, choose from (44100, 22050, 11025) )「建议收藏」

    【错误记录】FFmpeg 推流报错 ( FLV does not support sample rate 8000, choose from (44100, 22050, 11025) )「建议收藏」[flv@0xe9e24600]FLVdoesnotsupportsamplerate8000,choosefrom(44100,22050,11025)[flv@0xe9e24600]Audiocodecmp3notcompatiblewithflv

    2022年10月16日
    3
  • 程序员的生存法则_程序员的一生

    程序员的生存法则_程序员的一生前几天,和国内某知名企业的行销一线喝茶聊天,他一直在抱怨自己的上司很差劲,一直允诺追加奖金,但是月底考评结果却给的很差,奖金也没别人的多,所以他想调别的部门。我很是惊诧,这公司是你们家开的?怎么可以想调就调?他笑了笑说,你不懂职场生存法则吗?    他的工作需要经常出差,全国各地跑。上次是去江西,他知道部门A的老大老家在江西,就主动去找A部门老大,告之有个出差机会,要不要一起?后来我才明白“要不

    2022年10月7日
    4
  • 无人机指挥系统中标价_云睿智能无人机

    无人机指挥系统中标价_云睿智能无人机为什么大规模数字孪生很重要?Geopipe数据如何独特地使开发人员能够构建创新的空间产品?犹他大学的一个跨学科团队为无人机系统(UnmannedAerialSystems,UAS)…

    2022年8月15日
    6
  • html5表格内容怎么居中_html表格上下居中

    html5表格内容怎么居中_html表格上下居中回答:IE6/7及IE8混杂模式中,text-align:center可以使块级元素也居中对齐。其他浏览器中,text-align:center仅作用于行内内容上。解决这个问题比较好的方式,就是为所有需要相对父容器居中对齐的块级元素设置“margin-left:Auto;margin-right:Auto”。但这个方式IE6/IE7/IE8的混杂模式中不支持,所以还要设置父容器的”text…

    2022年9月14日
    2
  • java uniqueresult_「uniqueresult」hibernate uniqueResult方法 – seo实验室[通俗易懂]

    java uniqueresult_「uniqueresult」hibernate uniqueResult方法 – seo实验室[通俗易懂]uniqueresult数据库中根据你的查询条件只会返回唯一结果,就可以用uniqueresult这个方法!否则就用list();其返回类型为ObjectuniqueResult()方法通常是在业务方法查询语句中用到的,比如(Usersroles)getsession().createQuery(“selecturfromUsersRolesurwhereur.role.id=?…

    2022年9月11日
    2
  • [Warning] large integer implicitly truncated to unsigned type [-Woverflow][通俗易懂]

    [Warning] large integer implicitly truncated to unsigned type [-Woverflow][通俗易懂][Warning]largeintegerimplicitlytruncatedtounsignedtype[-Woverflow]警告的原因是:整数溢出整数溢出:当整数达到它所能表述的最大值时,会重新从起点开始#include<stdio.h>intmain(void){ unsigneda=12345678910; printf(“a=%d\n”,a); return0;}该程序输出以后并不是输出a=12345678910而是:上面的代码

    2022年7月25日
    8

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

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