• 执行SQL查询报:The incoming request has too many parameters错误
  • 发布于 2个月前
  • 965 热度
    1 评论

我有个代码在执行Linq查询时系统报如下错误,有哪位大神知道是怎么回事,要怎么处理的?错误信息如下:


The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.
我的Linq查询语句如下,这个requestIDList有1万多个RequestID



        public static List<V_InvestmentDetail> GetInvestmentDetailList(List<int> requestIDList)
        {
            using (InvestmentBudgetApplicationDataContext dc = new InvestmentBudgetApplicationDataContext(BLLHelper.ConnectionString()))
            {
                var query = from n in dc.V_InvestmentDetails orderby n.RequestID descending where requestIDList.Contains(n.RequestID) select n;
                return query.ToList();
            }
        }


用户评论
  • 深山夕照
  • 解决方式1:我看你这个只是查询视图表的资料,而且只是查询RequestID属于某些值的情况,你可以直接改成用SQL语句select * from V_InvestmentDetail where RequestID in (这边把入参的RequestID拼接成1,2,34,5这样)就可以了。

    解决方式2. 把入参的数组拆分成几个子数组来查询,单个数组的长度不要超过2000个RequestID

  • 2022/8/22 15:53:00 [ 0 ] [ 0 ] 回复