dapper

How do I map multiple lists with dapper

て烟熏妆下的殇ゞ 提交于 2020-01-11 11:45:10
问题 I've got three classes User, Order & Project which are stored in single tables. The orders and projects both have a n:n relation with the users. To implement that I've got two crosstables (UserOrders, UserProjects) which map these relations. public class User { public string UserID {get;set;} public List<string> Orders{get;set;} public List<string> Projects {get;set;} } public class Order { public string OrderID {get;set} ... } public class Project { public string ProjectID {get;set} ... } As

Dapper: Execute a command multiple times and linq and ToArray

孤人 提交于 2020-01-11 11:18:55
问题 According to the dapper docs one can write connection.Execute(@"insert into MyTable(colA, colB) values (@a, @b)", new[] { new { a=1, b=1 }, new { a=2, b=2 }, new { a=3, b=3 } } ) I tried using conn.Execute( @" insert into RelRoleUser ( RoleID, UserID ) values( @roleID, @userID )", userroleList.Select(r => new { roleID = r.roleID, userID = r.userID }).ToArray(), null, null, null); But get an exception "Invalid type owner for DynamicMethod" in Dapper code private static Action<IDbCommand,

ORM-Dapper:Dapper列表

北城以北 提交于 2020-01-08 10:29:16
ylbtech-ORM-Dapper:Dapper列表 1. 返回顶部 1.1、 https://dapper-tutorial.net/ 1.2、 2.1、 https://www.nuget.org/packages/Dapper/ 2.2、 2. 返回顶部 3. 返回顶部 1.1、 https://dapper-plus.net/ 1.2、 https://dapper-plus.net/online-examples 1.3、 4. 返回顶部 5. 返回顶部 6. 返回顶部 作者: ylbtech 出处: http://ylbtech.cnblogs.com/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 来源: https://www.cnblogs.com/storebook/p/11121235.html

一款高效开发平台简介,基于微软.net平台

早过忘川 提交于 2020-01-06 23:18:56
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 平台介绍 Learun快速开发平台是一个.net中后台应用解决方案(.net分布式快速开发框架);前端基于Bootstrap,促使前端高效开发;后端基于ASP.NET MVC5和Dapper框架,提供一套快速开发框架。平台实现通用的基础功能、权限验证、安全验证,为中小型企业提供稳定、高效、安全、便捷的一体式框架。 平台功能 地址 https://www.learun.cn/ 基础功能 l 用户登录/修改密码/退出 l 菜单管理/用户管理(数据授权、权限授权、新增用户) l 用户安全控制(重置密码、用户操作异常锁定、修改密码等) l 权限管理中心(自定义表单权限、普通权限) l 精细化权限控制,控制到按钮的显示 l 数据字典管理/单据编码管理 l 登录日志/操作日志/访问日志/异常日志 l 文件上传/图片上传 l 通用导入导出excel功能 l 定时任务/任务管理/任务监控 高级功能 l 数据权限管理和验证 l 平台模板管理和发布 l 文章管理和发布 l 智能查询 平台特点 来源: oschina 链接: https://my.oschina.net/u/4148883/blog/3153387

How to return List<dynamic> with Dapper.NET ORM that can bindable?

烈酒焚心 提交于 2020-01-06 07:09:52
问题 This question is old now, Dapper data-view binding are fixed as shown answer below :) 回答1: I've added TypeDescriptor -based bindings to DapperRow , which means that anything obtained via Query() (the dynamic API) should now bind to much common UI controls. Anything from 1.60.5 or above should work. Let me know! Caveat: it doesn't currently work for empty results (zero rows). I know how to implement that (see notes here), but that would require some additional changes to the query

How to return List<dynamic> with Dapper.NET ORM that can bindable?

て烟熏妆下的殇ゞ 提交于 2020-01-06 07:09:20
问题 This question is old now, Dapper data-view binding are fixed as shown answer below :) 回答1: I've added TypeDescriptor -based bindings to DapperRow , which means that anything obtained via Query() (the dynamic API) should now bind to much common UI controls. Anything from 1.60.5 or above should work. Let me know! Caveat: it doesn't currently work for empty results (zero rows). I know how to implement that (see notes here), but that would require some additional changes to the query

How to use Parameter List of integers for Oracle with Dapper?

筅森魡賤 提交于 2020-01-06 06:48:33
问题 I am trying to re-write some code to use Dapper so I can easily use parameters. I am trying to execute an UPDATE statement on an Oracle database. A list of IDs to UPDATE is passed in as List<int> as parameter. I want to update a field for each of the IDs passed in. The following is what I have: OracleConnection connection = ... // set earlier public int IncreaseProcessCount(List<int> ids) { var rowsAffected = connection.Execute(@"UPDATE TABLE SET PROCESSED_COUNT = PROCESSED_COUNT + 1 WHERE ID

How to insert multiple integer parameters into query?

时间秒杀一切 提交于 2020-01-06 05:40:12
问题 Website user can enter search criteria to query orders. User, States, Status, OrderID, etc. Website communicates with API. Query parameters are in the header, so I assume they come in as strings. API communicates with Access via Dapper. For some criteria, they can send multiple values. So I want to use an "IN" clause. where UserID in (150, 3303, 16547) Dapper handles this nicely. connection.Query<int>("select * from table where Id in @Ids", new { Ids = new int[] { 1, 2, 3 } }); This works in

What's the difference between [Computed] and [Write(false)] attributes?

瘦欲@ 提交于 2020-01-05 08:31:57
问题 This resource explains how Computed excludes a property (in an update only?). Specifie the property should be excluded from update. [Table("Invoice")] public class InvoiceContrib { [Key] public int InvoiceID { get; set; } public string Code { get; set; } public InvoiceKind Kind { get; set; } [Write(false)] [Computed] public string FakeProperty { get; set; } } using (var connection = My.ConnectionFactory()) { connection.Open(); var invoices = connection.GetAll<InvoiceContrib>().ToList(); //

Dapper Query incorrectly maps the entity ID

…衆ロ難τιáo~ 提交于 2020-01-04 14:12:26
问题 I have 2 entity classes: public class PostTag { public int Id { get; set; } public string Alias { get; set; } public string Name { get; set; } public int Level { get; set; } } public class PostTagIndex { public int Id { get; set; } public int PostTagId { get; set; } } I want to draw attention to the fact that both of them have the same field named 'Id'. Next, I use Query(...) method this way: List<PostTag> postTags = cn.Query<PostTag>(postTagsSql, new { postId }).AsList(); Here is the