多数の NOLOCK を含む SQL ステートメントがあります。いくつかの調査を行った後、LINQ to SQL でこれを処理する方法を見つけました。これが私がやった方法です:
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"};
}
問題は、このエラーが表示され、それに関する情報が見つからないことです。
'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?)