dapper

Traditional sql approach VS ORM [closed]

时光毁灭记忆、已成空白 提交于 2019-12-23 01:16:16
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago . I am really frustrated of searching this answer that what is better - Traditional System.Data.SqlClient approach or using any ORM like EF or Dapper I have seen many comparisons through many links, some are : https://github.com/StackExchange/dapper-dot-net http://www

Nullable DateTime and Dapper Dot Net

只愿长相守 提交于 2019-12-22 08:03:01
问题 I have a Type with a nullable DateTime column. When I try to use Dapper Dot Net to create a collection of that Type, I run into problems. Scenario 1 : If all the rows are null for this column it's fine Scenario 2 : If one or more the rows have a date value for this column, I get the following error: Error parsing column 3 (LastCompleted=2013-12-03 00:00:00 - DateTime) - Invalid cast from 'System.DateTime' to 'System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral,

Dapper multi mapping two properties of the same type

谁说我不能喝 提交于 2019-12-22 06:59:43
问题 Let's say I have contacts stored in my database in a flattened form, such that I query them like this: SELECT Name, HomeHouseNumber, HomePostcode, WorkHouseNumber, WorkPostcode FROM Contacts I would like a little more structure in my C# code and have this simple definition of a contact with a home and work address. class Address { public string HouseNumber { get; set; } public string Postcode { get; set; } } class Contact { public string Name { get; set; } public Address HomeAddress { get;

Transactions in “dapper-dot-net”

我只是一个虾纸丫 提交于 2019-12-22 06:56:01
问题 How do I create a transaction if my DAL is using dapper-dot-net? My c# winform application will be used in network and the data will be saved to a central sql server. My use case requires use of transactions. Can I do this using dapper, or will I need to use something like NHibernate? Also, is there any risk or limitation with this framework if I am using stored procedures? Will I need to change my approach due any possible limitations? 回答1: I haven't run into any limitations with using

SecurityException - Dapper on shared hosting

回眸只為那壹抹淺笑 提交于 2019-12-22 05:58:07
问题 For my current project I use Dapper. Everything perfect. Then I needed to deploy it on shared hosting. The result can be seen here (copied YSOD): Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: Request for the permission of type

Dapper: is it possible to customize the type mapping of a specific field of a specific type?

落花浮王杯 提交于 2019-12-21 20:22:30
问题 Let's say I have this User class: public class User { public int ID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string Email { get; set; } public DateTime DateCreated { get; set; } public DateTime LastLogin { get; set; } } Which I want to map to the following table: CREATE TABLE "user" ( "ID" int(11) NOT NULL AUTO_INCREMENT, "FirstName" varchar(45) DEFAULT NULL, "LastName" varchar(45) DEFAULT NULL, "Email" varchar(255) NOT NULL, "DateCreated

Is there a way to remove the default dependency on Entity Framework within MVC 4?

孤者浪人 提交于 2019-12-21 13:07:34
问题 Is there a way to remove the default dependency on Entity Framework within an ASP.NET MVC 4 project and replace it with another similar technology such as Dapper 回答1: If you create a new ASP.NET MVC 4 Web Application and choose "Internet Application" as the project template you will notice that Entity Framework is referenced and used as part of SimpleMembership. However, there is only a very small dependency on Entity Framework and it probably isn't worth removing it. Entity Framework appears

Dapper and Oracle CRUD issues, how to?

扶醉桌前 提交于 2019-12-21 12:19:09
问题 How do i make Dapper.NET to CRUD my Oracle DB? I have table named: PLAYER_LOG it's identity is done by trigger, here is the sql SELECT SQ_MASTER_SEQUENCE.NEXTVAL INTO tmpVar FROM dual; :NEW.ID := tmpVar; my Model is: public class PlayerLogStorage : IEntity //-> here is the identity { public string Cli { get; set; } public string PlayerAnswer { get; set; } public DateTime InsertDate { get; set; } } here is my insert: using (IDbConnection ctx = DbConnectionProvider.Instance.Connection) { ctx

Dapper sqlmapperextensions automatically adds “s” to tablename?

倾然丶 夕夏残阳落幕 提交于 2019-12-21 09:04:11
问题 This is my first experience with Dapper.Contrib (latest version from Nuget) and it's a strange situation: using (SqlConnection cn = new SqlConnection(connectionString)) { cn.Open(); var product = cn.Get<Product>(1); } On SqlMapperExtensions, it raises the error Invalid object name 'Products' : public static T Get<T>(this IDbConnection connection, dynamic id, IDbTransaction transaction = null, int? commandTimeout = null) where T : class { var type = typeof(T); string sql; if (!GetQueries

Can I return a collection of multiple Derived Types from Dapper query

…衆ロ難τιáo~ 提交于 2019-12-21 07:22:18
问题 I have a class structure similar to this: public abstract class Device { public int DeviceId { get; set; } //Additional Properties } public class DeviceA : Device { //Specific Behaviour } public class DeviceB : Device { //Specific Behaviour } I need to retrieve a list of Devices, or a single Device which is instantiated as the appropriate derived type (based upon a Type value in the Device Record in the DB). That is, the collection of Device objects should contain a number of objects with