Linq to sql LINQ到SQL不明确';隔离级别';介于'之间;系统.数据.隔离级别';和';System.Transactions.IsolationLevel';
我有一个SQL语句,里面有一堆NOLOCK。在做了一些研究之后,我发现了一种在LINQtoSQL中处理这个问题的方法。我是这样做的:Linq to sql LINQ到SQL不明确';隔离级别';介于'之间;系统.数据.隔离级别';和';System.Transactions.IsolationLevel';,linq-to-sql,Linq To Sql,我有一个SQL语句,里面有一堆NOLOCK。在做了一些研究之后,我发现了一种在LINQtoSQL中处理这个问题的方法。我是这样做的: int year = 2011; int quarter = 4; DateTime timeframe = new DateTime(year, (quarter * 3), 01).AddMonths(1); using (var txn = new TransactionScope( TransactionScopeOption.Requir
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"};
}
如果让我猜一下,您有一个
using
语句,用于System.Data
和System.Transactions
。问题是在这两种类型中都有一个称为IsolationLevel的类型,编译器不知道使用哪一种类型。请删除System.Data引用,或执行以下操作
new TransactionOptions
{
IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
}
如果让我猜一下,您有一个
using
语句,用于System.Data
和System.Transactions
。问题是在这两种类型中都有一个称为IsolationLevel的类型,编译器不知道使用哪一种类型。请删除System.Data引用,或执行以下操作
new TransactionOptions
{
IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
}
看起来像这样的代码:
new TransactionOptions
{
IsolationLevel = IsolationLevel.ReadUncommitted
}
应该是:
new TransactionOptions
{
IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
}
看起来像这样的代码:
new TransactionOptions
{
IsolationLevel = IsolationLevel.ReadUncommitted
}
应该是:
new TransactionOptions
{
IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
}
你知道你可以完全限定类型名吗?@Kirk Woll:不知道。我甚至不知道它在找什么。但它起了作用。谢谢。你知道你可以完全限定类型名吗?@Kirk-Woll:不知道。我甚至不知道它在找什么。但它起了作用。谢谢。@Darren Kopp:添加系统。交易成功了。谢谢你的帮助。@Darren Kopp:添加系统。交易成功了。谢谢你的帮助。@Mike Corcoran:是的,这就解决了问题。谢谢你的帮助。如果答案解决了你的问题,就接受它。我在VS生成的一些代码上也有同样的问题。非常感谢。@Mike Corcoran:是的,这就解决了它。谢谢你的帮助。如果它解决了你的问题,请接受答案。我对VS生成的一些代码也有同样的问题。非常感谢。