Dapper.Contrib icon indicating copy to clipboard operation
Dapper.Contrib copied to clipboard

dapper.contrib insert single data always return 0 but the data is inserted in database successfully

Open zhw511006 opened this issue 8 years ago • 4 comments

I have a simple user class,

public class User { [Key] public GUID UserId {get; set;} public string Firstname {get; set;} public string Lastnmae {get; set;} }

When I call Insert(user) mehtod, alwasy return 0;

But I put user in list

List<User> users = new List<User>(); users.add(user);

and then call Insert(users) return 1;

I don't know why.....Thanks for your help!

zhw511006 avatar Aug 19 '16 12:08 zhw511006

At a guess, it is expecting to return the "identity", but that table doesn't have an "identity" column (a guid primary key is not the same)

On 19 Aug 2016 1:42 p.m., "Moonlight" [email protected] wrote:

I have a simple user class,

public class User { public GUID UserId {get; set;} public string Firstname {get; set;} public string Lastnmae {get; set;} }

When I call Insert(user) mehtod, alwasy return 0;

But I put user in list

List users = new List(); users.add(user);

and then call Insert(users) return 1;

I don't know why.....Thanks for your help!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/StackExchange/dapper-dot-net/issues/587, or mute the thread https://github.com/notifications/unsubscribe-auth/AABDsBvI94PNGy3tc80bi_GBtHR9UZEuks5qhaS3gaJpZM4JocC- .

mgravell avatar Aug 19 '16 21:08 mgravell

Nobody met this problem?

zhw511006 avatar Aug 23 '16 06:08 zhw511006

Suggestion?

zhw511006 avatar Sep 07 '16 01:09 zhw511006

The issue is Dapper trying to get a int out of this. We'll fix with generics in v2, tagging as such.

NickCraver avatar Jan 28 '17 14:01 NickCraver