tmsmith / Dapper-Extensions

Dapper Extensions is a small library that complements Dapper by adding basic CRUD operations (Get, Insert, Update, Delete) for your POCOs. For more advanced querying scenarios, Dapper Extensions provides a predicate system. The goal of this library is to keep your POCOs pure by not requiring any attributes or base class inheritance.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get methods is not map model Guid?(nullable guid) property

EyupEnsar opened this issue · comments

Hello,

I have a uniqueidentifier type field that can be left blank in the table, I don't have any problems while recording, but when I want to retrieve the data, this field is empty for all data.

I realized that this is because the type of the field in the code is Guid?(nullable guid).

I request your support in this matter.

image
image
image

note: When the field is Guid(not nullable), data comes in, but because my field is defined as ForeignKey in the database, it gives an error while saving the data.

Hello, just to clarify, the information is coming from the same table or from the related one?

Could you please send the mapping information and how you are retrieving data?

commented

Hi, i have same problem. MS SQL, null FK uniqueidentifier. Property name in class and collumn name in DB are same, I am using automap only. In runtime, when property is type of Guid?, values read from table are always null. When i changed in Entity class property to type Guid, values are mapped (dbnull values are mapped to Guid.Empty) I cannot use Guid, as inserting Guid.Empty violates FK constraint. FK is nullable.