views:

93

answers:

1

What is the Linq equivalent for row locking hints in SQL? For example:

select *
  from MyTable with (updlock)
 where MyField like 'A%'

Or is the whole question moot, because Linq caches all the objects anyway and it can't handle concurrent updates to an object already residing in memory?

+2  A: 

It doesn't work; Linq has no mechanism for this. It'd be nice to have, but it's hard to provide locking hints in a database-independent way. However, you can still use stored procedures or System.Transactions to achieve the same effect.

David Seiler