Collection fetch

Sep 21, 2015 at 12:08 PM
I have a IEnumerable<something> collection which is building on demand from a source. I would like to fetch all objects containing the values indexed where a given property is in that collection. If you want, something similar with "where FIELD IN (values-list)" from SQL.

I know this could be done via "foreach (value in my collection) rdb.Query(value);" - but I was thinking it would be better because we skip an [possibly] unnecessary step like 'query' parsing and so on.

Thanks!
Sep 22, 2015 at 7:19 AM
Currently there is no IN for the query predicates but you can simulate it :
var result = rdb.Query<T>(x => x.name == val1 || x.name == val2 ...); // if you know the values
var result = rdb.Query("viewname", "name=val1 or name=val2 or ...); // if the values are dynamic -> you create the filter string
Sep 22, 2015 at 9:32 AM
Thanks a lot. I'll do that.

The thing is the collection is quite large (1000+ ids), it is populated from a separate thread with a cadence of 5-10 items per second. I was thinking I could 'save' some cycles and not have to run the Query method with each fetched result (avoid expression compilation, tests and whatever other things are done when Query is called).
Sep 22, 2015 at 9:39 AM
If I understand correctly the IN clause has 1000+ items?!

If that is the case I would just Query() the 5-10 items when ever they are added if your system/application allows it/makes sense.

Generally don't worry about performance... that's my job :)