C# 事务(进程ID 56)被锁定?

C# 事务(进程ID 56)被锁定?,c#,asp.net,sql-server,linq-to-sql,C#,Asp.net,Sql Server,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 == de

在这里,我使用的是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();
            }
IEnumerable DD=(来自DealDbContext1.Deals中的D
其中D.Address==City&&(D.DealTime>=DateTime.Now | | D.DealTime==dealcheck)&&PriceMax>=D.DealPrice&&D.DealPrice>=PriceMin&&DealTempMax>=D.SavingsRate&&D.SavingsRate>=DeatTime.Now.AddDays(TimeMin)&&D.DealTime 0&&lstSite[0]!=“所有交易”)
{
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)在与另一个进程的锁|通信缓冲区资源上死锁,并被选为死锁受害者。请重新运行该事务


提前感谢…

看起来您在同时扫描表/clustindex和更新/删除时遇到了一般死锁锁定问题

查看生成的查询及其paln(如果它有这样的扫描),尝试使用适当的索引避免它,或将其改为使用(NOLOCK)提示。但是如果您需要准确一致的数据,而不需要可能的幻影行,NOLOCK提示就不好了


和-首先,查看死锁图!

SQL Server的错误日志中将有一个死锁条目,您可以发布它吗?如果没有,请打开查询运行需要多长时间?SQL Server的哪个版本?否则设置为下次捕获此项。SQL Server的错误日志:客户端无法重新使用SPID为81的会话,该会话已被重置为连接池。失败ID为29。此错误可能是由以前的操作失败引起的。请检查错误日志,查看此错误消息之前的失败操作