Reputation: 13205
I would like to apply a Criteria query to an in-memory collection of entities, instead of on the database. Is this possible? To have Criteria API work like LINQ? Or alternatively, convert Criteria query to LINQ query.
Thanks!
Upvotes: 1
Views: 572
Reputation: 11661
It sounds like you're rolling your own caching mechanism. I would highly recommend checking out NHibernate's 2nd level cache. It handles many complex scenarios gracefully such as invalidating query results on updates to the underlying tables.
http://ayende.com/Blog/archive/2009/04/24/nhibernate-2nd-level-cache.aspx
Upvotes: 1
Reputation: 4287
I don't believe you can use Criteria to query against an in-memory collection and come to think about it it doesn't seem to make much sense. If I'm understanding everything correctly you've already queried against your database. I'd suggest to either tune your original query (whichever method you choose) to include all of your filters. Or you could use LINQ (as you suggested) to refine your results.
Also, what's your reasoning for wanting to query from memory?
Upvotes: 1