how to use table hints in Linq to sql when call submit changes method
dataContext.table2.something = dataContext.table1.something;
dataContext.SubmitChanges();
i want to use it like this sql code:
declare @var int;
begin transaction
select @var = something from table1 with (HoldLock);
update table2 set something = @var;
update table1 set something = @var + 1;
commit transaction;
This is not possible.
Actually, it is possible by doing serious nasty hacking using reflection. You can compile a query, and then fiddle with the generated SQL string in some internal object. This is the least desirable way to do this.
I recommend you stay with raw SQL for this one.
I've always heard that cant be done. Linq's goal (or at least one of them) is take or mind out of SQL so you dont have to worry with things like this. I suggest that you add your code with the table hint to a SQL procedure and use Linq to call it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With