dapper

Populating POCO's with ServiceStack.OrmLite

▼魔方 西西 提交于 2019-12-07 23:51:08
问题 Consider the following domain model: class Customer { int id {get;set} string Name {get;set} List<Contact> Contacts {get;set} } class Contact { int id {get;set} string FullName {get;set} List<PhoneNumber> {get;set} } class PhoneNumber { int id {get;set} PhoneType Type {get;set} string Number {get;set} } Customer, Contact & PhoneNumbers are separate entities in our DB. Any Suggestions as to how to populate a full customer with all its linked contacts and the contacts phone numbers in the most

Can't get Dapper to handle SQL RowVersion properly

与世无争的帅哥 提交于 2019-12-07 20:17:26
I've got a rowversion column added to my database and I'm trying to get Dapper mapping to populate it properly on my object. My object has... public byte[] RowVersion { get; set; } And I have included the RowVersion column in my query but when I do a Query.. conn.Query<MyObject, AnotherObject, AnAdditionalObject>(... The MyObject that I get passed to me has a null for the RowVersion property. If I do a Dapper Query() without any type then the dynamic I get back has the expected RowVersion on it with the correct value. Has anyone had this working and if so what am I doing wrong? I was able to

Dapper Spatial Geography Type

余生长醉 提交于 2019-12-07 14:08:59
问题 I'm cooking up some spatial examples and have decided to give Dapper a go, although EF has spatial support, and I'm loving having control over my SQL again (Thanks Sam & Marc). However, I need to be able to have POCO's that support the DbGeography class. For example : public class BuriedTreasure { public int PirateId { get; set; } public DbGeography MarksTheSpot { get; set; } } My Google foo has been letting me down and the closest match I can find is this question, though it only caters for

Dapper,decimal to double? Error parsing column X

混江龙づ霸主 提交于 2019-12-07 13:38:13
问题 My database is Oracle. I user Dapper 1.13, which throws an exception saying Error parsing column 3 (LATITUDE=39.2330 - Decimal) . LATITUDE is a double? type in my entity. Please help me. Thanks 回答1: Yep, that's a bug; have fixed locally - basically, change line 2367 (wow, when did that file get so big?) from: il.Emit(OpCodes.Ldtoken, unboxType); to: il.Emit(OpCodes.Ldtoken, Nullable.GetUnderlyingType(unboxType) ?? unboxType); Basically, it is emitting: (decimal?)Convert.ChangeType(val, typeof

Can I use DynamicParameters with Template and have a return parameter in dapper?

天大地大妈咪最大 提交于 2019-12-07 11:33:40
问题 The system I am currently working on uses Stored Procedures for all data access. I'm looking into Dapper at the moment (so far it looks great) but I was wondering if I can use a DynamicParameters object created using a Template but make one of the parameters an output param. For example: SP: CREATE PROCEDURE InsertPerson @ID int Output, @Name varchar(100), @DOB DateTime2 AS --INSERT STATEMENT SET @ID = SCOPE_IDENTITY() POCO: internal class Person { public int ID { get; set; } public string

分布式追踪系统---google的dapper

时光总嘲笑我的痴心妄想 提交于 2019-12-07 10:15:12
最近看了google的分布式追踪系统dapper的论文: http://static.googleusercontent.com/external_content/untrusted_dlcp/research.google.com/zh-CN//pubs/archive/36356.pdf ,结合自己的理解描述下。 一、 引子: 用户输入关键字后只要敲个回车键就能返回搜索结果(图1a),这样一个简单的过程可能涉及到上千个服务,可能需要上千个服务器协作完成。如图1b所示,user发了RequestX请求到达A,A通过rpc(远程过程调用,如thrift)调用B以及C,而C又需要通过rpc调用D以及E等等。 对user的一次请求,他迟迟未收到响应ReplyX,或者响应时间很慢,我们需要确认性能到底消耗在哪个环节,这个时候我们该怎么办呢?自然是分析我们的日志。 我们每个服务都会有请求日志,请求日志记录着一次调用所花费的时间,比如对A来说,记录着调用B所花费的时间以及调用C所花费的时间,同理C的请求日志记录着调用D以及E所花费的时间。对于互联网应用来说,各个服务比如B,同一时刻可能有成百上千次请求记录。 这种日志有个致命 缺点---没有将这些记录与特定的请求关联一起 。对于user的一条特定的请求RequestX,我们不知道B日志中哪条记录与之对应,也不知道C日志中哪条记录与之对应。。

PostgreSQL, Npgsql returning 42601: syntax error at or near “$1”

自闭症网瘾萝莉.ら 提交于 2019-12-07 08:21:54
问题 I'm trying to use Npgsql and/or Dapper to query a table and I keep running into Npgsql.PostgresException 42601: syntax error at or near "$1". Here is what I've got trying it with NpgsqlCommand: using (var conn = new NpgsqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["postgres"].ConnectionString)) { conn.Open(); using (NpgsqlCommand command = new NpgsqlCommand("select * from Logs.Logs where Log_Date > current_date - interval @days day;", conn)) { command.Parameters

Dapper Extensions Change Schema

假如想象 提交于 2019-12-07 06:24:22
问题 I am using Dapper Extensions to do some simple CRUD operations on a DB. My problem is that the tables I am using are held in a different schema to dbo. Is there a way to choose the schema at the dapper extensions level? or Should this be dealt with via the user that is being used to connect to the db with? 回答1: You can use the AutoClassMapper to assign a new schema to your model. An overview on this is on the extensions site. You will basically need to create an AutoClassMapper per model with

Output parameter is always null with multi.Read

泄露秘密 提交于 2019-12-07 05:21:45
问题 We are using Dapper.Net extensively and are very happy with it. However we have come across an issue when trying to retrieve output parameters from stored procedures using multi.Read : var p = new DynamicParameters(); p.Add("@id", id); p.Add("TotalRows", dbType: DbType.Int32, direction: ParameterDirection.Output); using (var multi = cnn.QueryMultiple(string.Format("dbo.[{0}]", spName), p, commandType: CommandType.StoredProcedure)) { int TotalRows = p.Get<int>("@TotalRows"); //This is always

Filling and binding two combobox WPF Caliburn.micro

无人久伴 提交于 2019-12-07 05:09:32
问题 I have this table: I use in my project this view Called NewItem and in this view there is two combobox. I would like to do this : that in the combobox Group there are all DESCRIPTION of table GROUP, and when i choose an item of this description (of first combobox) the second combobox fills of descriptions relating only to that description that I have chosen before. This is some code: XAML NewItemView: <ComboBox Height="21" HorizontalAlignment="Left" Margin="89,99,0,0" VerticalAlignment="Top"