c# - System.Data.Linq.dll 上的堆栈溢出异常

标签 c# asp.net sql iis linq-to-sql

我最近正在开发一个 ASP.NET Web 应用程序。使用 linq to sql ORM 到数据访问层 (DAL)。在我的查询在 clr 级别面临 stackoverflow 异常的特定情况下。

我使用过滤表达式生成器来获取特定数据(例如使用特定约束的加载),我们将超过 1500 个参数发送到存储过程。

注意:我们认为 RPC(远程过程调用)限制正好是 2100 sql server默认设置中的参数。

但我不知道为什么我会遇到 stackoverflow 异常?有趣的是,这个问题只发生在 iis 上,而在 asp.net Web 开发服务器上没有问题。

我快要找出因参数过多而导致的问题了。

我对帮助我的人表示感谢?

Exception Detail

 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/

相关文章:

c# - 模拟时无法将 "comctl32.dll"DLL 加载到内存中

javascript - 更新面板后 JS 被重置

c# - 如果我在 Codebehind 中创建一个文件,物理文件实际存在于何处?

c# - Asp.Net,从上一页访问变量是一种好方法吗?

sql - SQL-内部联接2个表,但如果1个表为空则返回全部

sql - UNION 多个存储过程的结果

c# - Selenium - C# - Webdriver - 无法找到元素

c# - 如何统计某些符号出现的次数?

c# - 无法在 ASP C# 中切换到 DropDownList 中的另一个值(它切换回以前的值)

sql - 组合两个具有多个粒度级别的表