Yas*_*ahu 6 c# sql-server asp.net linq-to-sql
在这里,我正在使用Linq to sql我的表中有超过30000行.
我使用以下查询从数据库中获取记录:
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();
}
Run Code Online (Sandbox Code Playgroud)
有一段时间我的查询成功运行或有一段时间我得到错误:事务(进程ID 56)在锁定时死锁 与另一个进程通信缓冲资源并被选为死锁牺牲品.重新运行该交易.
提前致谢...
看起来您在同时进行表/簇索引扫描和更新/删除时遇到了一般死锁锁定问题
查看生成的查询及其结果 - 如果它有这样的扫描 - 尝试通过适当的索引来避免它或破解它以使用 (NOLOCK) 提示。但是,如果您需要精确且一致的数据且没有可能的幻行,则 nolock 提示并不好
并且 -首先看死锁图!
| 归档时间: |
|
| 查看次数: |
6080 次 |
| 最近记录: |