dapper-extensions

How to remove trailing spaces and change encoding in char(n) columns in dynamic ExecuteQuery

流过昼夜 提交于 2021-02-17 07:07:21
问题 ASP.NET MVC Core 5 application uses Npgsql to get data from Postgres database. Columns in database are defined as CHAR(n) type, like: create table prpalk ( sfirmanimi char(100) ); Column types cannot be changed to varchar. Postgres database encoding is unicode. However some columns are in custom encoding which needs to be converted to unicode to be used in .NET. Those column names in database start always with word Custom. I tried Dapper to get data but data contains trailing spaces and

How to remove trailing spaces and change encoding in char(n) columns in dynamic ExecuteQuery

a 夏天 提交于 2021-02-17 07:06:15
问题 ASP.NET MVC Core 5 application uses Npgsql to get data from Postgres database. Columns in database are defined as CHAR(n) type, like: create table prpalk ( sfirmanimi char(100) ); Column types cannot be changed to varchar. Postgres database encoding is unicode. However some columns are in custom encoding which needs to be converted to unicode to be used in .NET. Those column names in database start always with word Custom. I tried Dapper to get data but data contains trailing spaces and

MySQL + Dapper Extensions: Error in SQL syntax

走远了吗. 提交于 2021-02-08 05:46:18
问题 I am trying to do CRUD operations using Dapper Extensions. But I am getting error while inserting data to MySQL database as follows: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near [......] at line [....] If I use MSSQL database, Dapper Extensions is working correctly. Why I am getting this error with MySQL? 回答1: The error is because Dapper Extensions is generating the query for SQL server (by default

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

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

Why can't I set “this” to a value in C#?

筅森魡賤 提交于 2019-12-29 02:05:48
问题 I am using Dapper.net Extensions and I would like to be able to retrieve a Photo object and set 'this' to it without having to set each property individually. What would be the best way to accomplish this? In the code below it says I cannot assign to 'this' because it is readonly. public class Photo { public Int32 PhotoId { get; set; } public Guid ObjectKey { get; set; } public Int16 Width { get; set; } public Int16 Height { get; set; } public EntityObjectStatus ObjectStatus { get; set; }

Dapper QueryMultiple Stored Procedures w/o mapping to Objects

主宰稳场 提交于 2019-12-23 22:36:37
问题 With dapper, I can do batch execute for Stored Procedures, something similar to: connection.Execute(@" exec sp1 @i = @one, @y = @two exec sp2 @i = @three", new { one = 1, two = 2, three = 3 }); However, the only means of retrieving data that I have seen till now is by using results.Read<Type>() What if the results don't map to an object? For instance, I am writing "generic" code to execute any SP with variable in/out parameters & result sets. Thanks 回答1: What API do you want? If you can