dapper

Dapper & TransactionScope?

不问归期 提交于 2020-01-20 13:21:36
问题 I just started playing around with Dapper. So far i love it. Does dapper not work with TransactionScope ? I noticed that even if i never call TransactionScope.Complete then my changes are still committed to the database. If TransactionScope isn't supported now is there any plans in the future to support it? If not then you have to use traditional transaction management (System.Transactions.Transaction)? Update: I just talked to Sam over Twitter. It should work. I'll update it tomorrow morning

Dapper Extension Ms Access System.Data.OleDb.OleDbException

丶灬走出姿态 提交于 2020-01-20 07:13:47
问题 I just started to use Dapper. Dapper works fine. As a next step when I tried to integrate with Dapper Extension. It generates an exception called System.Data.OleDb.OleDbException "Additional information: Characters found after end of SQL statement." Why is that? Dapper Extension doesn't support Ms Access (because of the end character) or problem with my code or I am missing something. My code is below using (var conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source

APM 原理与框架选型

假装没事ソ 提交于 2020-01-19 21:06:44
发些存稿:) 0. APM简介 随着微服务架构的流行,一次请求往往需要涉及到多个服务,因此服务性能监控和排查就变得更复杂: 不同的服务可能由不同的团队开发、甚至可能使用不同的编程语言来实现 服务有可能布在了几千台服务器,横跨多个不同的数据中心 因此,就需要一些可以帮助理解系统行为、用于分析性能问题的工具,以便发生故障的时候,能够快速定位和解决问题,这就是APM系统,全称是( A pplication P erformance M onitor,当然也有叫 A pplication P erformance M anagement tools) AMP最早是谷歌公开的论文提到的 Google Dapper 。Dapper是Google生产环境下的分布式跟踪系统,自从Dapper发展成为一流的监控系统之后,给google的开发者和运维团队帮了大忙,所以谷歌公开论文分享了Dapper。 1. 谷歌Dapper介绍 1.1 Dapper的挑战 在google的首页页面,提交一个查询请求后,会经历什么: 可能对上百台查询服务器发起了一个Web查询,每一个查询都有自己的Index 这个查询可能会被发送到多个的子系统,这些子系统分别用来处理广告、进行拼写检查或是查找一些像图片、视频或新闻这样的特殊结果 根据每个子系统的查询结果进行筛选,得到最终结果,最后汇总到页面上 总结一下:

C# Database Mapper

∥☆過路亽.° 提交于 2020-01-15 18:44:50
问题 I was looking to map my database query results to strongly type objects in my c# code. So i wrote a quick and dirty helper method on the SqlConnection class which runs the query on the database and uses reflection to map the record columns to the object properties. The code is below: public static T Query<T>(this SqlConnection conn, string query) where T : new() { T obj = default(T); using (SqlCommand command = new SqlCommand(query, conn)) { using (SqlDataReader reader = command.ExecuteReader

Mapping JSON response from SQL Server to a single string

为君一笑 提交于 2020-01-15 11:02:11
问题 Im returning a complex object from the sql server as a JSON. But when im mapping to a List of String in dapper, the JSON string is being mapped to more than one string in the list depending upon the JSON length even though in DB i can see only one row for the result. So im having to append all the strings in the list and then deserialize the JSON to a object. I know it doesn't make a huge difference in terms of performance but why should i append all the string when i can directly deserialize

Mapping JSON response from SQL Server to a single string

旧城冷巷雨未停 提交于 2020-01-15 11:01:41
问题 Im returning a complex object from the sql server as a JSON. But when im mapping to a List of String in dapper, the JSON string is being mapped to more than one string in the list depending upon the JSON length even though in DB i can see only one row for the result. So im having to append all the strings in the list and then deserialize the JSON to a object. I know it doesn't make a huge difference in terms of performance but why should i append all the string when i can directly deserialize

Using CustomPropertyTypeMap to map specific properties

雨燕双飞 提交于 2020-01-15 05:49:07
问题 I have a couple of classes that need to have one or two properties (out of several dozen) mapped to a column on a table that has a different column name. I don't want to map all of the properties, when only two differ from the column names in the database. I can't find decent docs on all of the various mapping options that can be used with the CustomPropertyTypeMap, they all just show mapping the entire object with the CustomPropertyTypeMap (as does the Dapper tests class). When I use the

Does Dapper support c# 6 read-only properties in POCOs?

萝らか妹 提交于 2020-01-14 07:49:12
问题 Given the following: public class SomePoco { public int IntValue { get; } } and CREATE TABLE SomePocoStorage (IntValue INT NOT NULL) and INSERT SomePocoStorage VALUES (1), (274) If I call connection.Query<SomePoco>("SELECT * FROM SomePocoStorage") does Dapper handle populating the IntValue field on the returned SomePoco instances? 回答1: Good question! It isn't a scenario I've targeted, but I'd be more than happy to take a look at what would be involved. Since we already do a lot of nasty

TypeHandler<T> doesn't seem to be called

谁都会走 提交于 2020-01-12 15:18:09
问题 The short version SqlMapper.Query<T> seems to ignore my registered TypeHandler<T> The long version Here's a simple query: SELECT 'Foo' AS CategoryName, 200 AS CategoryRating ...and here's two POCOs: public class RatingValue { public Int32 Value { get; set; } // ... some other properties etc ... } public class MyResult { public String CategoryName { get; set; } public RatingValue CategoryRating { get; set; } } I've created a new TypeHandler implementation which should turn that CategoryRating

How do I map multiple lists with dapper

不想你离开。 提交于 2020-01-11 11:45:46
问题 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