admin管理员组文章数量:1122846
Our clients want to do a single query to a Person table that fetches the records whose integer ids are included in a large list, often thousands of ids at once, e.g.:
List<int> idsOfRecordsToRetrieve = (list of 5000 ids starting with 100, 205, 215);
List<Person> people = new XPQuery<Person>(session).Where(p => idsOfRecordsToRetrieve.Contains(p.Id).ToList();
A problem we have is that the SQL ends up being written like:
select ... from Person where id in (@p0, @p1, @p2 ... @p0 = 100, @p1 = 205, @p2 = 215 ...
But we hit the SQL Server parameter limit because it tries to create a parameter for every id
Is there some way to prevent it from making parameters like this and write out something more like
select ... from Person where id in (100, 205, 215 ...)
Within the limitations of our client's requirements and the system we're working with, it would be very hard to break up that query or find something else in common between all the records we want to query that uses up fewer parameters
For now, we are trying to migrate to other systems which allow us to generate better SQL (or at least have more control over how our SQL is generated), but there is pressure to come up with some immediate solution
I mean, sometimes there is no immediate solution, but I'm hoping there are some options out there
本文标签: aspnetPrevent XPO from generating SQL with too many parametersStack Overflow
版权声明:本文标题:asp.net - Prevent XPO from generating SQL with too many parameters? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736311233a1934663.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论