I have a SQL statement with a bunch of NOLOCKs in it. After doing some research I came across a way to deal with this in LINQ to SQL. Here is how I did it:
int year = 2011;
int quarter = 4;
DateTime timeframe = new DateTime(year, (quarter * 3), 01).AddMonths(1);
using (var txn = new TransactionScope(
TransactionScopeOption.Required,
new TransactionOptions
{
IsolationLevel = IsolationLevel.ReadUncommitted
}))
{
// Your LINQ to SQL query goes here
var results =
from wo in WORKORDERs
join wot in WORKORDERTYPEs on wo.Wot_oi equals wot.Wotyoi
join pri in PRIORITies on wo.Prio_oi equals pri.Priooi
join s in SITEs on wo.BEparn_oi equals s.Siteoi
where wo.Audt_created_dttm.Value.Year >= year - 3 && wo.Audt_created_dttm.Value.Year >= 2006
&& wo.Audt_created_dttm < timeframe && (s.Id =="NM" || s.Id == "TH") &&
(!wot.Id.Contains("stand") && wo.Ci_cnc_date != null && pri.Prioid != "1 - Routine") &&
(pri.Prioid.Contains("1") || pri.Prioid.Contains("2") || pri.Prioid.Contains("3"))
select new {PM = wo.Wosource, Site = s.Id, Priority = pri.Prioid, Worktype = wot.Id,
WoNumber = wo.Id, Description = wo.Aenm, CreateDate = wo.Audt_created_dttm,
CloseDate = wo.Clsdt_date, Planning =
(pri.Prioid == "1 - Routine" || pri.Prioid == "6 - Planned Outage") ? "Planned" : "Unplanned"};
}
The problem is that I receive this error and can find no information on it.
'IsolationLevel' is an ambiguous reference between 'System.Data.IsolationLevel' and 'System.Transactions.IsolationLevel'
Cannot implicitly convert type 'System.Data.IsolationLevel' to 'System.Transactions.IsolationLevel'. An explicit conversion exists (are you missing a cast?)
it looks like this code:
should be: