Denis Biondic
Denis Biondic

Reputation: 8201

NHibernate - best strategy to map ID which isn't identity

Just a quick question, how would one map a primary key which must be assigned manually (data type int). So, there is no identity in the database, if code was manually written you would probably open a transaction, lock the table, take the highest id, increment by one, and insert the record with the new value.

Upvotes: 1

Views: 105

Answers (2)

Denis Biondic
Denis Biondic

Reputation: 8201

Actually, I used the increment generator, which somehow I've overlooked to exist. It has some constraints about its usage, but it suits the situation for now.

Upvotes: 0

s1mm0t
s1mm0t

Reputation: 6095

Set the Id generator to be assigned. Find more info at http://barchitect.blogspot.com/2008/07/nhibernate-generator-and-primary-key.html

Upvotes: 2

Related Questions