we can use sql just like this:select * From Student with(nolock)
how can i impl this in Linq to sql?
Note:I don't want to use TransactionScope
expect your answer
we can use sql just like this:select * From Student with(nolock)
how can i impl this in Linq to sql?
Note:I don't want to use TransactionScope
expect your answer
LINQ to SQL does not have any mechanism of doing this, but you can create a transaction with a specific isolation level. Look at the code below:
using (var con = new SqlConnection("constr"))
{
con.Open();
using (var tran = con.BeginTransaction(IsolationLevel.ReadUncommitted))
{
using (var context = new SchoolDataContext(con))
{
context.Transaction = tran;
var q = from s in context.Students select c;
}
}
}
Sometimes using this type of isolation is useful, i.e. for performance reasons. But please make sure you don't do any create, update or delete (CUD) operations using this type of database isolation. It of course depends on your situations, but your data could get in an inconsistent state.