分享.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)
上一篇 2021年8月28日 下午9:00
下一篇 2021年8月28日 下午9:00


相关推荐

  • Ubuntu下gcc安装及使用

    Ubuntu下gcc安装及使用在Ubuntu下安装GCC和其他一些Linux系统有点不一样。一、安装方法一:sudoapt-getbuild-depgccsudoapt-getbuild-depgcc方法二:sudoapt-getinstallbuild-essentialsudoapt-getinstallbuild-essential安装…

    2022年7月24日
    17
  • JavaSE: Java10的新特性

    JavaSE: Java10的新特性1.Java10的概述<1>Java10于2018年3月发布,改进的关键点包括一个本地类型推断、一个垃圾回收的增强<2>Java10计划只是一个短期版本,因此公开更新将在

    2022年7月4日
    19
  • Java遍历数组逗号的使用[通俗易懂]

    Java遍历数组逗号的使用[通俗易懂]1.错误示例当直接拼接”,”号会在结尾也输出多余的”,”号输出示例2正确示例用判断语句来写当x等于(arr.length的长度-1)满足时,也就是数组arr[4],会在arr[4]后面输出一个”]”号,//(至于为什么不是在arr[4]前面输出”]”,参考java基本结构:顺序结构)当这个条件不满足才会输出”,”号输出示例我是java自学小萌新【闲云】…

    2026年1月26日
    3
  • java中return用法总结

    java中return用法总结Java 中 return 用于方法 两个作用 nbsp nbsp 1 返回方法指定类型的值 这个值总是确定的 也可以是对象 nbsp nbsp 2 方法的结束两种形式 1 有返回类型例如 returni nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp 2 无返回类型 nbsp return 一般方法前有 void 代表无返回值 没有 void 有返回值 例 1publicclass

    2025年7月27日
    5
  • 吹嘘的AI大模型Claude Code换成GLM-4.7也没神马区别

    吹嘘的AI大模型Claude Code换成GLM-4.7也没神马区别

    2026年3月12日
    2
  • linux的打包压缩文件,linux打包文件,压缩文件

    linux的打包压缩文件,linux打包文件,压缩文件1 打包 linux 下最常用的打包程序就是 tar 了 使用 tar 程序打出来的包我们常称为 tar 包 tar 包文件的命令通常都是以 tar 结尾的 生成 tar 包后 就可以用其它的程序来进行压缩 1 命令格式 tar 必要参数 选择参数 文件 2 命令功能 用来压缩和解压文件 tar 本身不具有压缩功能 他是调用压缩功能实现的 3 命令参数 必要参数有如下 A 新增压缩文件到已存在的压缩 B 设置区块大小

    2026年3月16日
    2

发表回复

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

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