我有个代码在执行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