LockMode is for existing entities. You cannot lock for the "non-existence" 
of an entity with that.
You have to use a transaction with a strong isolation level instead 
(IsolationLevel.Serializable). Inside this transaction, you should check 
for the existence of your entity, then take appropriate action, and only 
then finish the transaction. Of course, using strong isolation levels 
should be done carefully: it can lead to deadlocks.

(An other option could be to perform a SqlQuery using something like 
"MERGE" (sql 2008: 
http://msdn.microsoft.com/fr-fr/library/bb510625(v=sql.100).aspx ). But of 
course, this means working directly on your table records rather than with 
entities.)

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to