There's no way currently to work around the 2100 parameter limit in sqlserver till Microsoft lifts that limit for their batching API. We looked into alternatives but there aren't that many (concat everything to a string, split it on the server, etc.).
I’m guessing jamming everything into temp tables and joining to the table probably didn’t work or was just not feasible?
We don't want to inline values in a query no matter what. Integers sound simple enough but other values might also be simple, or hit the 2100 limit, plus we want to avoid embedding elements in a query at all, if we allow one thing what more is allowed? that is a confusing message and we don't want to give that.
I agree that may be confusing, but if it was disabled by default and had appropriate warnings given in the documentation I think it wouldn't be out of line with similar solutions in other libraries. I only mentioned integer values because those are most often PK identifiers and don’t seem to be susceptible SQL injection or similar security risks. That said, giving the user the ability to select different data types that do or do not get inlined in an IN clause would be fine as well.
In the end, I think giving the developer the option to make the decision would be preferable, as that seems to be the trend with other major ORM options.
That said, in general these values come from somewhere. If they're from the database, it might be you could replace the 2100 values with a subquery that produces them.
Unfortunately, that’s often not the case for us, or if it is it increases the complexity of various querying solutions (we've had challenges getting nested queries to work when using IQueryables, which is what we nearly always use). It’s often the case that a user has the ability to view and report on large sets of data, and then select various filters from large lists.
For example, it’s common for the user to do something like pull back a report of 2500 orders, and I want to see invoice data tied to any of those items, but only if they tie to a list of 50 products at 10 locations. All the keys we want to filter on are integer primary keys, but I need to batch the ids and either pull back more data than I need to and filter by product/location in memory or implement some kind of nested batching where I keep track of how many parameters I’ve used (even though it’s not always 1 to 1). The in-memory filtering works, but sometimes it means we end up pulling way more info back from the database than we need.
Having 2100 values in an IN clause is pretty slow btw, and as you hit a limit, you're going to send way more. 10,000?
In my experience, it’s not really been that slow, or at least the tradeoff between speed and code complexity ends up being worth it. The +2100 parameter case happens often enough that just about everything has to work with more parameters than that, but it doesn’t happen often enough that it significantly impacts the day-to-day user experience.
You mention using subqueries a lot, is there a good resource/page in your documentation on best practices with writing subqueries using LINQ IQueriables? We’ve just tried that in the past and haven’t had success (we get various kinds of errors about being unable to cast subqueries into different types), but it’s possible we’ve just been using it wrong. I did a bit of searching in your documentation but its likely that my google-fu isn't that great.
And thanks again for taking the time to respond!