I have a scenario where I have a table of “batch” and a table of “test” where “test” contains an FK to “batch” and a many tests can belong to a batch.
I want to be able to select multiple batches and find all tests that belong to them. I do this by producing a list of PKs to the batches I’m interested in and then the following LINQ query:
var ret =
from t in tests
from b in indices //indices is a list of long PK's belonging to selected batches
where t.batch_id == b
select t;
It works but when my selection size exceeds 14 batches, I get a “SQLite error
parser stack overflow” on the LINQ expression regardless of how many tests are found.
I want to be able to handle large selections if possible. How can I do this?
The LINQ provider may be blowing up because it’s trying to issue 1 query per index. You can verify this (if SQL is in fact getting generated at all) by profiling the DB and seeing if it’s actually issuing 1 query per index.
Try this instead: