How to make large "in" queries in C# for an indexed field in MSSQL? In mssql, how can I run effectively this query:
select id from table where field in (gigantic list of ordered longs)

Table schema:
table:
{
  id primary key
  field long
} index findex (field)

I think this should be really fast (since it's basically just stepping through two ordered lists of longs).  Is there a way to continuously stream the IDs in?
I can do it from a console or using Linqpad/SSMS.
Current (slow) Solution: a console app which constructs many long queries, each with 3k fieldId arguments.  The limit on argument number is the problem; how to get around it?
select id from table where field in (gigantic list of ordered longs)

Queries with long IN lists are slow, as they are parsed and compiled each call.
Either pass the list as a JSON array:
select id from table where field in (select value from openjson(@values))

Or use a Table-Valued Parameter or bulk load a temp table with the values. Ensure there is an index or primary key. The OPENJSON method will likely be slower, but the upside is that it works with all client drivers.  TVP and Bulk Insert are not always available except in .NET and Java.