Dapper-Extensions icon indicating copy to clipboard operation
Dapper-Extensions copied to clipboard

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

Open EyupEnsar opened this issue 3 years ago • 2 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.

EyupEnsar avatar Jun 15 '22 13:06 EyupEnsar

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?

valfrid-ly avatar Jul 11 '22 12:07 valfrid-ly

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.

votrelec avatar Jan 18 '23 12:01 votrelec