此 RPC 请求中提供了太多参数。 最大为2100。?

发布于 2024-07-24 23:58:44 字数 105 浏览 3 评论 0原文

搜索查询返回了此错误。 我有一种感觉,因为当我尝试 ORM 另一个对象时,in 子句在从属对象上是巨大的。

显然 in 子句不应该一次构建 1 个参数。 谢谢伊巴蒂斯。

A search query returned this error. I have a feeling its because the in clause is ginormous on a subordinant object, when I'm trying to ORM the other object.

Apparently in clauses shouldn't be built 1 parameter at a time. Thanks ibatis.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

戴着白色围巾的女孩 2024-07-31 23:58:44

最好的办法是修改您的应用程序,将少于 2100 个参数传递给存储过程。 这是无法提高的 DBMS 限制

Your best bet is to revise your application to pass less than 2100 parameters to the stored procedure. This is a DBMS limit that can't be raised.

神回复 2024-07-31 23:58:44

当使用明显无辜的 LINQ to SQL 查询时,我遇到了同样的错误。 我只是想检索 id 包含在数组中存储的所有记录:

dataContext.MyTable.Where(item => ids.Contains(item.Id)).ToArray();

事实证明 ids 数组有超过 2100 个项目,并且 DataContext 似乎在结果中为数组中的每个项目添加了一个参数SQL 查询。

最后,这是我的代码中的一个错误,因为 ids 数组不必有这么多项目。 但无论如何,值得记住的是,在 LINQ to SQL 中使用此类构造时需要一些额外的验证。

I got this same error when using an apparently innocent LINQ to SQL query. I just wanted to retrieve all the records whose ids were amongst the ones stored in an array:

dataContext.MyTable.Where(item => ids.Contains(item.Id)).ToArray();

It turned out that the ids array had more than 2100 items, and it seems that the DataContext adds one parameter for each item in the array in the resulting SQL query.

At the end it was a bug in my code, since the ids array had not to have so many items. But anyway it is worth to keep in mind that some extra validation is needed when using such constructs in LINQ to SQL.

提笔落墨 2024-07-31 23:58:44

您可以执行以下操作:

  1. 将参数放入临时表中,并使用所述临时表来过滤您的查询。 请参阅 https://stackoverflow.com/a/9947259/37055
  2. 创建一个逗号分隔的数组,并将该数组传递到SQL Server 作为 varchar(x)。 通过 TSQL 将其拆分(这里有一些方法)并使用生成的行集来过滤搜索结果。
  3. 查看您的应用程序逻辑。 将 2100 个参数传递给存储过程有点奇怪。

You can do a few things:

  1. Pump the params into a temp table and use said temp table to filter your query. See https://stackoverflow.com/a/9947259/37055
  2. Create a comma-delimited array, and pass the array into SQL Server as a varchar(x). Split it out via TSQL (here are a few methods) and use the resulting rowset to filter your search results.
  3. Have a look at your application logic. It's more than a little strange to be passing 2100 parameters to a stored procedure.
失而复得 2024-07-31 23:58:44

如果您向单个存储过程传递 2100 个参数,那么您只是做错了什么。 不要提高限制或试图解决这个令人厌恶的问题,找出如何正确做事的方法。

If you are passing 2100 parameters to a single stored procedure, you are simply doing something wrong. Don't raise the limit or try to work around this abomination, figure out how to do things right.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文