I have Fluent NHibernate Linq queries where I check values based on run time arrays. A basic example would be something like:
var array = [1,2,3,4,5,6];
usin
Use Any:
return session.Query().Where(x => array.Any(y => y == x.CompareVal)).ToList();
Your repository pattern (using plain Func) automatically materializes your query to list, if you want something to be deferredly executed, use IQueryable, don't use Func only
Something to note - I have a Generic Repository class that all of these calls are funneled through. The Query method is as follows:
public IList Query(Func criteria)
{
using (var session = SessionProvider.SessionFactory.OpenSession())
{
return session.Query().Where(criteria).ToList();
}
}
Your repository just mimic what is already provided out of the box by NHibernate