我最近正在开发一个 ASP.NET Web 应用程序。使用 linq to sql ORM 到数据访问层 (DAL)。在我的查询在 clr 级别面临 stackoverflow 异常的特定情况下。
我使用过滤表达式生成器来获取特定数据(例如使用特定约束的加载),我们将超过 1500 个参数发送到存储过程。
注意:我们认为 RPC(远程过程调用)限制正好是 2100 sql server默认设置中的参数。
但我不知道为什么我会遇到 stackoverflow 异常?有趣的是,这个问题只发生在 iis 上,而在 asp.net Web 开发服务器上没有问题。
我快要找出因参数过多而导致的问题了。
我对帮助我的人表示感谢?
public List<HSEPersonnelComplexPaging> SelectHSEPersonnelPaging(PagingPropertiesDTO pagingProps, out int recCount)
{
using (HRPaidTimeOffDataContext db = new HRPaidTimeOffDataContext(DBHelper.GetConnectionString()))
{
Expression<Func<HSEPersonnelComplexPaging, bool>> expr =
PredicateBuilder.GetFilterExpression<HSEPersonnelComplexPaging>(pagingProps);
db.DeferredLoadingEnabled = false;
var items = from at in db.HSEPersonnels
where at.IsDeleted == false
select new HSEPersonnelComplexPaging
{
ID = at.HSEPersonnelId,
PersonnelyNo = at.PersonnelyNo,
Name = at.Name,
Family = at.Family,
BirthPlace = at.BirthPlace,
Birthdate = at.Birthdate,
Father = at.Father,
IdNo = at.IdNo,
NationalCode = at.NationalCode,
IsNotActive = at.IsNotActive,
IsDeleted = at.IsDeleted,
InsertDate = at.InsertDate,
UpdateDate = at.UpdateDate,
InsertENTUserAccountId = at.InsertENTUserAccountId
};
var result = items.Where(expr);
recCount = result.Count();
return
result.ApplySortExpression(pagingProps.SortSet).Skip(pagingProps.CurrentPageIndex *
pagingProps.CurrentPageSize).Take(
pagingProps.CurrentPageSize).ToList();
}
最佳答案
问题可能出在您正在构建的谓词上。当您枚举表达式(在调用 Count()
中执行此操作)时,LINQ to SQL 将沿着表达式树向下查找,以确定您要查询的内容。您是否有可能在某个地方创建循环引用?
关于c# - System.Data.Linq.dll 上的堆栈溢出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17809026/