The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Too many parameters were provided in this RPC request. The maximum is 2100.
表示你踩到IN Parameter最多2100個的限制。
以下為我的解決之道:
double dLoopCycle = (containList.Count / 2000); int loopCycle = Convert.ToInt32(Math.Ceiling(dLoopCycle)); loopCycle = loopCycle == 0 ? 1 : loopCycle; Listresult = new List (); List tempResult = new List (); //more than 2100 parameter would raise error for (int i = 0; i < loopCycle; i++) { int rangeIndex = (i * 2000); var tempList = containList.GetRange(rangeIndex, Math.Min(2000, containList.Count - rangeIndex)); tempResult = (from r in DataContext.Test where tempList.Contain(r.ID) select r).ToList(); result = result.Union(tempResult ); }
另外oracle的SQL也有IN Parameter不得超過1000個的限制,這個就會在後續的文章分享我的解決方式囉~~
[ASP.NET] 解決Oracle IN clause 超過1000個參數
沒有留言:
張貼留言