【发布时间】:2013-07-22 10:54:00
【问题描述】:
我最近正在开发一个 asp.net 网络应用程序。使用 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();
}
【问题讨论】:
-
为什么返回一个列表而不是一个 IEnumerable?
-
“我们向存储过程发送了 1500 多个参数” - 哦,我的。
-
@doctorlove 通过分页解决负载我确实需要列表
并将计数记录到 Telerik radgrid UI。 -
@CodeCaster 哦,是的,在 Linq To Sql 中我们不能发送表值参数来查询!!!
标签: c# asp.net sql iis linq-to-sql