dapper

Dapper control dates

狂风中的少年 提交于 2019-12-12 04:30:10
问题 This question is meant to bring some light around control date times using Dapper . These controls are used to audit the information in a data storage and figure out when a particular row has been created / updated. I couldn't manage to find any information on GitHub's project, either here in StackOverflow, so I would like this post to become a central source of truth to help others or even to turn into a future extension of the library. Any answer, resource or best practice will be

DNXCORE 5.0 and mysql / mariadb

跟風遠走 提交于 2019-12-12 01:28:44
问题 For a new project which has to target Linux and Windows, I am searching for a solution to support MySQL (or MariaDB). Because we have to support those different platforms I wish to work on DNX Core5.0. However I can't find any nuget packages / connectors which I can use to connect to the database. the one that i find are not supported by DNX core 5.0. Is there a way to connect to mysql in DNX core 5.0 ? Or do you have to fall back on ODBC connections, i don't know if this would work...

Unable to run update statement using Dapper (parameters error)

大兔子大兔子 提交于 2019-12-11 23:22:58
问题 I am trying to update a row using Dapper but I am having error on specifying parameters in my update statement An exception of type 'System.InvalidOperationException' occurred in IBM.Data.DB2.iSeries.dll but was not handled in user code Additional information: Not enough parameters specified. The command requires 3 parameter(s), but only 0 parameter(s) exist in the parameter collection. Repository.cs public void Update(Movie movie) { var sql = "UPDATE myDB.movies set title=?, genre=? where Id

How is it better to send data using Dapper in c# to PL/SQL scripts variables of RECORD type

一世执手 提交于 2019-12-11 16:24:17
问题 I have a PL/SQL procedure that using 3 variables of RECORD type as parameters, which i have to fill with my data (from c# application) to execute a procedure. 1st i've tried to build the same structure with this records via c# and pass as a parameter via Dapper, but it's not working since dapper works only with scalar data types. Then i've tried to pass my data as arrays and to map them inside the procedure, but RECORD type can't accept sets of data like a.NAME := ('aaaaaa','sdasd'); it works

Cant find any way to group by multi dapper result

北城余情 提交于 2019-12-11 15:07:33
问题 I have this query: const string query = @" select * from [Users] u left join [UserRoles] ur on [ur].[UserId] = [u].[UserId] left join [Roles] r on [r].[RoleId] = [ur].[RoleId] left join [ExternalLogins] el on [el].[UserId] = [u].[UserId]; "; and next class structure: public sealed class User : IUser<string> { public string Id { get { return this.UserId.ToString(); } } public Guid UserId { get; set; } public string PasswordHash { get; set; } public string SecurityStamp { get; set; } public

Is it possible to do this build this query with Dapper?

对着背影说爱祢 提交于 2019-12-11 13:59:22
问题 Is it possible do do the following? I tried, but when it got to the Query, it just said there was a null reference. var builder = new StringBuilder("select * from my table1 where 1 = 1"); if(x==1) builder.Append(" and x = @x"); if(y==2) builder.Append(" and y = @y"); // when it gets here, it just says null reference db.Query<table1>(builder.ToString(), new {x,y}); I got SqlBuilder to run in .net 3.5, but when I do this: var builder = new SqlBuilder(); var sql = builder.AddTemplate("select *

ORM基础知识

给你一囗甜甜゛ 提交于 2019-12-11 13:38:30
ORM基础知识 一.什么ORM? ORM是Object Relactional Mapping的缩写,即对象关系映射,是将关系型数据库中的数据库结构映射成对象,就可以通过面向对象思想编程。 二.常用的ORM框架有那些? Dapper、Entity Framework(EF) 三.常用的ORM框架之间的区别是什么? Dapper都是轻量级的框架 EF都是重量级的框架 来源: https://www.cnblogs.com/zlp520/p/12021899.html

ORM之Dapper

不想你离开。 提交于 2019-12-11 13:34:15
ORM之Dapper 一.下载安装: nuget 搜索dapper安装 二.使用: 三.优缺点: 优点: 1.开源、轻量、单文件( 代码就一个SqlMapper.cs文件,编译后就40K的一个很小的Dll) 2.简单易学,学习成本低 3.支持多数据库,比如: Mysql,SqlLite,Sqlserver,Oracle 4.执行效率高( Dapper的速度接近与IDataReader,取列表的数据超过了DataTable。Dapper原理通过Emit反射IDataReader的序列队列,来快速的得到和产生对象 ) 缺点: 1.代码量比较大( 实体类都要自己写 ) 2. 难以实现Repository模式 来源: https://www.cnblogs.com/zlp520/p/12021936.html

How to put objects into a dictionary using Dapper in C#?

余生颓废 提交于 2019-12-11 11:44:42
问题 I have a dictionary like the following: Dictionary<string,SP> dict; that contains a string and a SP object. I would like to do the following dict = conn.Query("SELECT routine_name,created,modified FROM PROCEDURES").toDictionary ( row => (string)row.Routine_Name, row => new SP (Name=row.Routine_Name,Created=row.created,Modified=row.modified)); The above code is not working. How can I create a SP object with the above information. I have a constructor that takes these three parameters. 回答1:

Dapper Build Object Tree Containing Same Object Type

我与影子孤独终老i 提交于 2019-12-11 10:06:12
问题 I have a single table which expresses a possible parent child relationship between Categories. Root categories would not contain a ParentId value, rather null. I think it's also important to point out that it should construct N level of depth. For example consider the following Sql table. Category : Id | Name | ParentId Where ParentId is a relationship back to the Id column of the same table. Trying to understand if it would be possible to populate the following class? public class Category {