dapper

Dapper ambiguous extension methods

馋奶兔 提交于 2019-12-01 14:58:38
问题 I am testing Dapper as a ORM solution and ran into a problem with some extension methods like Execute or QueryMultiple : using (SQLiteConnection con = new SQLiteConnection(GetConnectionString())) { con.Open(); string sql = @" select * from Customer where Id = @id; select * from Address where CustomerId = @id;"; // QueryMultiple extension ambiguous? using (var multi = con.QueryMultiple(sql, new { id = 1 })) { Customer customer = multi.Read<Customer>().Single(); Address address = multi.Read

Dapper with Access, update statement partially not working

吃可爱长大的小学妹 提交于 2019-12-01 14:57:35
I have a product class and tried to evaluate Dapper with Access database.. Select, Delete and Insert operations are working fine, but I have a problem with update operation. It is working in one way only code below) When I tried to change the Description based on ProductNumber it works (updateStatement2) and Description get updated, but when I tried to change the ProductNumber based on Description (updateStatement1) it doesn't work and ProductNumber doesn't get updated. It bit strange to me. Is it a bug or am I missing anything?. My database is just a basic one and no primary keys set. I have

Dapper: Multi-Mapping with repeating column names

杀马特。学长 韩版系。学妹 提交于 2019-12-01 13:05:27
I have a table that looks like this: ID ERR1 ERR2 ERR3 ---- ---- ---- ---- 05A2 A001 B223 C212 06B3 B392 C234 D234 ... I would like to map it to objects that look like this: public class Entry { public string Id { get; set; } public List<BpcError> Errors { get; set; } public Entry() { Errors = new List<BpcError>(); } } public class BpcError { public string ErrorCode { get; set; } // More properties and methods to follow } How can I do this? Here's how: string sql = "SELECT ID, " + "ERR1 AS ErrorCode, " + "ERR2 AS ErrorCode, " + "ERR3 AS ErrorCode " + "FROM ERR_TB"; List<Entry> entries =

Dapper with Access, update statement partially not working

与世无争的帅哥 提交于 2019-12-01 12:36:15
问题 I have a product class and tried to evaluate Dapper with Access database.. Select, Delete and Insert operations are working fine, but I have a problem with update operation. It is working in one way only code below) When I tried to change the Description based on ProductNumber it works (updateStatement2) and Description get updated, but when I tried to change the ProductNumber based on Description (updateStatement1) it doesn't work and ProductNumber doesn't get updated. It bit strange to me.

Dapper: Multi-Mapping with repeating column names

风流意气都作罢 提交于 2019-12-01 12:26:38
问题 I have a table that looks like this: ID ERR1 ERR2 ERR3 ---- ---- ---- ---- 05A2 A001 B223 C212 06B3 B392 C234 D234 ... I would like to map it to objects that look like this: public class Entry { public string Id { get; set; } public List<BpcError> Errors { get; set; } public Entry() { Errors = new List<BpcError>(); } } public class BpcError { public string ErrorCode { get; set; } // More properties and methods to follow } How can I do this? 回答1: Here's how: string sql = "SELECT ID, " + "ERR1

Jetson Nano Developer Kit

十年热恋 提交于 2019-12-01 10:55:09
  在使用Entity Framework这种ORM框架得时候,一般结合Repository仓储形式来处理业务逻辑;虽然这种模式带来很多好处,但是也会引发一些争议,在此抛开不谈,小弟结合项目经验来实现一下,欢迎大佬拍砖;      后续会带来Dapper 基于Repository实现,代码一些实现会兼容Dapper,所以做了一些比较丑陋得写法;但是我得想法是通过一些Ioc可以在Entity Framework和Dapper两者之间进行切换;      您可以通过Nuget:Install-Package MasterChief.DotNet.Core.EF 安装使用;      您可以通过Github:MasterChief 查看具体源码以及单元测试      The Jetson Nano Developer Kit is an AI computer for learning and for making.      一个推理框架,用于部署模型到嵌入式设备.      Four Steps to Deep Learning      System Setup      Image Recognition      Object Detection      Segmentation      CUDA      一种并行计算技术      编写自己的图像识别程序.     

分布式调用链监控组件的实践与比较(一)实践

荒凉一梦 提交于 2019-12-01 10:01:21
https://blog.csdn.net/ityouknow/article/details/82393097 引言:最近在调研与选型分布式调用链监控组件。选了主要的三种APM组件进行了实践与比较。本来打算一篇文章写完的,篇幅太长,打算分两篇。本文主要讲下链路traceing的基本概念和几种APM组件的实践,实践部分也没给出特别详细的步骤,因为本文重点不在具体的步骤。第二篇将会讲下几种APM选型的比较与性能测试。 1. 问题背景 微服务架构下,服务按照不同的维度进行拆分,一次请求请求往往需要涉及到多个服务。互联网应用构建在不同的软件模块集上,这些软件模块,有可能是由不同的团队开发、可能使用不同的编程语言来实现、有可能布在了几千台服务器,横跨多个不同的数据中心。因此,就需要一些可以帮助理解系统行为、用于分析性能问题的工具,以便发生故障的时候,能够快速定位和解决问题。 分布式调用链监控组件在这样的环境下产生了。最出名的是谷歌公开的论文提到的 Dapper 。开发Dapper是为了收集更多的复杂分布式系统的行为信息,然后呈现给Google的开发者们。这样的分布式系统有一个特殊的好处,因为那些大规模的低端服务器,作为互联网服务的载体,是一个特殊的经济划算的平台。想要在这个上下文中理解分布式系统的行为,就需要监控那些横跨了不同的应用、不同的服务器之间的关联动作。 市面上的APM

How Dapper.NET works internally with .Count() and SingleOrDefault()?

ⅰ亾dé卋堺 提交于 2019-12-01 09:52:32
I am new to Dapper though I am aware about ORMs and DAL and have implemented DAL with NHibernate earlier. Example Query: - string sql = "SELECT * FROM MyTable"; public int GetCount() { var result = Connection.Query<MyTablePoco>(sql).Count(); return result; } Will Dapper convert this query (internally) to SELECT COUNT(*) FROM MyTable looking at .Count() at the end? Similarly, will it convert to SELECT TOP 1 * FROM MyTable in case of SingleOrDefault() ? I came from NHibernate world where it generates query accordingly. I am not sure about Dapper though. As I am working with MS Access, I do not

Dapper multiselect: Nested class primary key doesn't map unless using “AS”

左心房为你撑大大i 提交于 2019-12-01 09:18:33
I have two classes: class Foo{ public int FooId { get; set; } ... public Bar Bar { get; set } } class Bar{ public int BarId { get; set; } public int FooId { get; set } ... } when i then run the query like this: sqlConnection.Query<Foo, Bar, Foo>( "SELECT * FROM Foo JOIN Bar ON Foo.FooId = Bar.FooId", (foo, bar) => { foo.Bar = bar; return foo; }, splitOn: "FooId"); the result would then be that all properties on both Foo and Bar will map up Except for Bar.BarId. After checking the column name and type in the database against my Bar class I still couldn't find any differences. One strange thing

Using Dapper to return XML string from T-SQL stored procedures

倖福魔咒の 提交于 2019-12-01 08:24:23
I am working on a project to convert a large VB6 application to .NET. I decided to create a project to provide a facade to the existing VB6 ADO code, where I am using the amazing Dapper extension methods to handle all the database code that the VB6 ADO functions used to do. One of the features I have to support in my new project is the ability to get the XML string results from T-SQL stored procedures (via the FOR XML). Dapper doesn't have support to return this XML that I can see. So, I implemented the ADO.NET ExecuteXmlReader method to provide this return. My project is also using Dapper