dapper

ServiceStack MARS (Multiple Active Result Sets) using ORMLite and Output Parameters

南楼画角 提交于 2019-11-30 09:25:36
ServiceStack ORMLite is great, I've typically steered clear of the ORM mentality preferring to build databases as it makes sense to build databases instead of a 1:1 class model. That said, there are a couple of things that I seem to be running into difficulty around, I'm certain it's simply my ignorance shining through. First: Is there a way to manage multiple result sets using ORMLite? I know that one can use the QueryMultiple method using Dapper, but for whatever reason I'm having a bear of a time figuring out how to use the built-in Dapper implementation of ServiceStack. Second: Is there a

Using Dapper with Oracle

时间秒杀一切 提交于 2019-11-30 08:56:24
We use Oracle as our database provider and have looked into replacing some of our data access layer (hard to maintain, harder to merge XSD's) with a saner repository based pattern using Dapper at the bottom layer. However, we have hit a number of issues when using it with oracle. Named Parameters: these seem to be ignored, whenever they are used in a query Oracle seems to interpret them in any order it fancies. The SqlMapper returns correctly named parameters, they just aren't interpreted correctly in Oracle The "@" naming convention for variables is incompatible with oracle named parameters.

Using Dapper.TVP TableValueParameter with other parameters

亡梦爱人 提交于 2019-11-30 08:20:09
I have a procedure that takes in a table-valued parameter, along with others: CREATE PROCEDURE [dbo].[Update_Records] @currentYear INT, @country INT, @records Record_Table_Type READONLY AS and am trying to call this with Dapper.TVP. Here is the code I have so far: var recordsParameter = new List<SqlDataRecord>(); // This metadata matches 'Record_Table_Type' in the Database var recordsMetaData = new[] { new SqlMetaData("OriginalValue", SqlDbType.Decimal, 19, 4), new SqlMetaData("NewValue", SqlDbType.Decimal, 19, 4), new SqlMetaData("NewPercent", SqlDbType.Decimal, 7, 2), }; foreach (var r in

Call custom constructor with Dapper?

心已入冬 提交于 2019-11-30 08:18:50
I'm trying to use Dapper to interface with the ASP.NET SQL Membership Provider tables. I wrapped the SqlMembershipProvider class and added an additional method to get me the MembershipUsers given a certain criteria relating to some custom tables I have. When querying the data with Dapper, it appears that Dapper first instantiates the class with a parameter-less constructor, and then "maps" the returned columns into the properties on the object. However, the UserName property on the MembershipUser class has a no setter. Judging from around line 1417 in the Dapper SqlMapper.cs, the method

Dapper AddDynamicParams for IN statement with “dynamic” parameter name

不想你离开。 提交于 2019-11-30 05:59:46
I have simple SQL string like this: "SELECT * FROM Office WHERE OfficeId IN @Ids" The thing is that the @Ids name is entered in an editor so it could be whatever, and my problem is that if I want to pass in, say an array of integers, it only works with Dapper if I use: var values = new DynamicParameters(); values.AddDynamicParams(new { Ids = new[] { 100, 101 } }); But this requires me to KNOW that the parameter name is Ids and that's not the case in my scenario. I can set a "dynamic parameter" in Dapper with a "dynamic" name like this: var values = new DynamicParameters(); values.Add("Ids",

Getting The connection does not support MultipleActiveResultSets when using Dapper.SimpleCRUD in a forEach

余生长醉 提交于 2019-11-30 05:02:48
问题 I have the following code: var test = new FallEnvironmentalCondition[] { new FallEnvironmentalCondition {Id=40,FallId=3,EnvironmentalConditionId=1}, new FallEnvironmentalCondition {Id=41,FallId=3,EnvironmentalConditionId=2}, new FallEnvironmentalCondition {Id=42,FallId=3,EnvironmentalConditionId=3} }; test.ToList().ForEach(async x => await conn.UpdateAsync(x)); I am getting the InvalidOperationException: The connection does not support MultipleActiveResultSets I don't understand I am await

分布式跟踪系统-cicada

好久不见. 提交于 2019-11-30 04:49:14
https://github.com/Yirendai/cicada/blob/master/cicada-docs/cicada_design.md 背景与目标 面对日趋复杂的分布式系统,如服务框架、消息中间件、缓存、数据层等,我司在业务性能瓶颈定位、故障排除等方面效率低下,生产环境中没有成熟的Trace工具,我们认为分布式跟踪系统适合且急需引入公司内部。 Trace系统需要能够透明的传递调用上下文,理解系统行为,理清后端调用关系,实现调用链跟踪,调用路径分析,帮助业务人员定位性能瓶颈,排查故障原因等;同时,需要对用户尽量透明,减少对业务代码的侵入性。 我们的Trace系统为解决以上问题而设计。 理论依据 目前可查的分布式跟踪系统,设计思想都源于Google的论文《Dapper, a Large-Scale Distributed Systems Tracing Infrastructure》。 现有Trace系统调研 调研期间,我们同时参考了其他互联网企业分布式跟踪系统的原理以及应用场景,例如阿里的Eagle eye,Twitter的Zipkin,京东的hydra以及点评的CAT。 Google Dapper && Alibaba Eagle eye 从实现来看,阿里的实现最接近Dapper论文中提到的方式。 Eagle eye架构如下图所示: 日志收集方式 记录本地文件

Is there a way to access the columns in a Dapper FastExpando via string or index?

时光毁灭记忆、已成空白 提交于 2019-11-30 04:41:36
I am pulling in a Dapper FastExpando object and want to be able to reference the column names dynamically at run time rather than at design/compile time. So I want to be able to do the following: var testdata = conn.Query("select * from Ride Where RiderNum = 21457"); I want to be able to do the following: foreach( var row in testdata) { var Value = row["PropertyA"]; } I understand that I can do: var Value = row.PropertyA; but I can't do that since the name of the property i'm going to need won't be known until runtime. The answer from this SO Question doesn't work. I still get the same Target

Is it possible to declare an anonymous type in C# with a variable/dynamic set of fields?

笑着哭i 提交于 2019-11-30 03:57:56
In C#, I would like to figure out if it's possible to declare an anonymous type where the fields are not known until run-time. For example, if I have a List of key/value pairs, can I declare an anonymous type based on the contents of that list? The specific case I'm working with is passing parameters to Dapper, where I don't know ahead of time how many parameters I will have. List<Tuple<string, string>> paramList = new List<Tuple<string, string>>() { new Tuple<string, string>("key1", "value1"), new Tuple<string, string>("key2", "value2") ... }; I'd like to convert this List (or an equivalent

When using the multi-mapping APIs ensure you set the splitOn param if you have keys other than Id“, ”splitOn

房东的猫 提交于 2019-11-30 02:56:06
I'm trying to use the Multi-mapping feature of dapper to return a list of Album and associated Artist and Genre. public class Artist { public virtual int ArtistId { get; set; } public virtual string Name { get; set; } } public class Genre { public virtual int GenreId { get; set; } public virtual string Name { get; set; } public virtual string Description { get; set; } } public class Album { public virtual int AlbumId { get; set; } public virtual int GenreId { get; set; } public virtual int ArtistId { get; set; } public virtual string Title { get; set; } public virtual decimal Price { get; set;