Questions tagged [dapper-contrib]

Dapper.Contrib contains a number of helper methods for inserting, getting, updating and deleting records.

Dapper.Contrib contains a number of helper methods for inserting, getting, updating and deleting records.

Source: https://github.com/StackExchange/dapper-dot-net/tree/master/Dapper.Contrib

47 questions
2
votes
1 answer

How can I make use of the collection accepting Dapper.Contrib methods?

Dapper.Contrib (https://github.com/StackExchange/Dapper/tree/master/Dapper.Contrib) states that they have several methods accepting IEnumerable lists, however I can not seem to find any of these methods. Using .NET Core 2, is this an outdated…
Timmeh
  • 398
  • 2
  • 14
2
votes
0 answers

Dapper.Contrib [Computed] Attribute does not allow property through on insert

Let me start off by saying, this is in no way a criticism. Dapper is an incredible tool, which I'm extremely happy to use. Dapper.Contrib being no different. Perhaps I'm misunderstanding the purpose of the [Computed] attribute. But the documentation…
pim
  • 12,019
  • 6
  • 66
  • 69
2
votes
2 answers

Dapper exception - Get only supports en entity with a [Key] property, but [key] is defined

If the BO is marked as having a key with [key], why does dapper through an error? [Table("tblWebReadyToWorkQualifications")] public class TeacherQualificationBO { [Key] public int TeacherID { get; set; } public string ReadyToWorkGuid {…
skunk
  • 83
  • 1
  • 8
2
votes
1 answer

Use Dapper.Contrib Update, with classes that have special helper properties

I am new to Dapper and Dapper.Contrib. There is a class like this and there is a table in database with the same name: public class Ware { public int ID { get; set; } public string Name { get; set; } public short UnitID { get;…
vaheeds
  • 2,594
  • 4
  • 26
  • 36
2
votes
1 answer

Does Dapper request a full object from the database prior to Linq operations?

I having been curious for awhile about how Dapper (or perhaps other ORMs) handle object retrieval when combined with LINQ. If I have a class like this: public static IEnumerable GetAll() { using (IDbConnection cn = new…
secretwep
  • 706
  • 1
  • 12
  • 28
1
vote
1 answer

How do I get back the key for a newly inserted record using Dapper.Contrib?

I have code like this: db.Insert(myObject); The key for the type myObject is of type System.Guid which is auto generated by RDBMS. I then want to insert child objects that will use that key to relate to their parents. foreach(var child in…
dpberry178
  • 558
  • 6
  • 21
1
vote
1 answer

How to Get entity by Unique Key using Dapper.Contrib?

I have an object, assume public class User { [Key] int TheId { get; set; } string Name { get; set; } int Age { get; set; } } TheId is my auto increment column and Name is my unique key. When saving a user, I want to check its…
Omer
  • 8,194
  • 13
  • 74
  • 92
1
vote
1 answer

Dapper.Contrib: How to get a row by filtering on column other than ID?

My class is like below: [Table("tblUser")] public class User { [Key] public int Id { get; set; } public string Title { get; set; } } Using Dapper.Contrib, is there a way to get the User record by Title instead of Id? If I query like…
Regi Mani
  • 61
  • 2
  • 4
1
vote
1 answer

Problem retreiving null on nullable bool with default value through dapper [contrib]

This might be a bit of an edge case, and maybe I'm wrong in my understanding of how default values work in this case. I have an issue where the below property is always returned as true even if it's null in the db. I guess this is due to the…
Mackan
  • 6,200
  • 2
  • 25
  • 45
1
vote
1 answer

How to avoid updating a column on subsequent Update calls using Dapper.Contrib?

I have a class Media that is mostly 1-to-1 with my DB table Media. I'm updating the table using Dapper.Contrib's Update SqlConnection extension method by passing in a Media object. One of my the columns of the table (and the corresponding class…
Imbajoe
  • 310
  • 3
  • 16
1
vote
1 answer

Dapper.Contrib + MS Access: Error - Characters found after the end of the SQL statement

I am using Dapper ORM with the Contrib package. The SELECT query works perfectly but my problem is when I try to INSERT data. Visual Studio 2017 returns this message: Characters found after the end of the SQL statement The basic query executed…
nboulfroy
  • 201
  • 3
  • 14
1
vote
1 answer

Inserting an entity if it doesn't already exist

We've been using Dapper and Dapper.Contrib for the ease in which we can perform regular database operations, which has been great. However, since introducing Polly to add retry policies for some of our operations, I've not been able to find a way to…
John H
  • 14,422
  • 4
  • 41
  • 74
1
vote
1 answer

Dapper.Contrib AS Entity, Why it fails?

Iam planning to use Contrib with dapper to make my classes in desktop applications look like this public abstract class DB : IDisposable { public virtual long Insert() { using (var db = ConFactory.GetConnection()) { …
msh
  • 15
  • 7
1
vote
1 answer

Store Procedures with Dapper.Contrib

I am newbie to Dapper and I Want to use Dapper.Contrib. Is there any method we can use store procedure with Dapper.Contrib methods. e.g The method of Dapper.Contrib is connection.GetAll().ToList();. I want to call store procedure in this…
Adeel Abbas
  • 31
  • 1
  • 6
0
votes
0 answers

Using Dapper to insert the default value of a column into the database when the property is set to null

I am trying to use Dapper and Dapper.Contrib to insert a whole object into a table in the databse, while ignoring (because the table has a default value for that column) the properties that have a value set to null. This is the class of the object I…