niico
niico

Reputation: 12749

Using property other than 'Id' for primary key in Dapper.net

Will Dapper.net work if I am using a property other than "Id" or "id" for the primary key of a table / object?

All I can see in the docs is something about "split on" which I do not follow.

Will it work for mapping inserts, updates & selects without being aware what the primary key is / without having an Id property?

Is anything else going to be different or not work by not having an Id field?

Upvotes: 2

Views: 1871

Answers (1)

Mrinal Kamboj
Mrinal Kamboj

Reputation: 11478

Will Dapper.net work if I am using a property other than "Id" or "id" for the primary key of a table / object?

Anytime without an issue, dapper will have no issue with this, dapper, being an object mapper, doesn't care much about the primary key

Except That

When you do Complex object mapping, which contains custom types, then with Id it can automatically split in the Query call and fill the objects. This is since they need some standard to fill objects, which can be overridden by supplying the SplitOn

Upvotes: 3

Related Questions