6
在這裏我正在與Linq到SQL我有更多然後30000行在我的表中。交易(進程ID 56)鎖定時死鎖?
我用下面的查詢從數據庫中獲取記錄:
IEnumerable<DealsDetails> DD = (from D in DealDbContext1.Deals
where D.Address == City && (D.DealTime >= DateTime.Now || D.DealTime == dealcheck) && PriceMax >= D.DealPrice && D.DealPrice >= PriceMin && DisCountMax >= D.SavingsRate && D.SavingsRate >= DiscountMin && (D.DealTime >= DateTime.Now.AddDays(TimeMin) && D.DealTime <= DateTime.Now.AddDays(TimeMax) || D.DealTime == dealcheck)
select new DealsDetails(
lst,
D.DealId,
D.DealHeadline,
D.DealCategory,
D.BuyPrice,
D.DealPrice,
D.SavingsRate,
D.SavingAmount,
D.RelatedWebsite,
D.Address,
string.Empty,
D.DealImage,
string.Empty,
string.Empty,
D.Time, D.CurrentTime, D.DealTime,
D.Location, string.Empty, string.Empty, D.Latitude, D.Longitude, D.Islocal, D.VendorMail, D.MerchantInfo, D.Review, D.HowItWork, D.DealUrl
));
if (lstSite.Count > 0 && lstSite[0] != "AllDeals")
{
DD = DD.Where(D => D.RelatedWebsite.Split(',').Where(x => lstSite.Contains(x)).Any()); //.Where(row => row.Category.ToList().Where(x => lst.Contains(x)).Any()).ToList();
}
一段時間我的查詢成功運行或一段時間我得到錯誤:事務(進程ID 56)被死鎖的鎖|通信緩衝區資源與另一個進程並被選爲死鎖受害者。重新運行交易。
在此先感謝...
在SQL Server的錯誤日誌中會出現死鎖條目,你可以發佈嗎?如果沒有,請打開[traceflag 1204或1222](http://msdn.microsoft.com/zh-cn/library/ms178104.aspx) – Andomar
查詢需要多長時間才能運行? – RobJohnson
什麼版本的SQL Server? [如果2008年查看是否可以從默認的擴展事件會話中獲取死鎖圖表](http://dba.stackexchange.com/questions/10644/deadlock-error-isnt-returning-the-deadlock-sql/10646#10646 )。否則,設置下次捕獲。 –