For my repository using the entity framework i'm using the following method to return a IList.
public virtual IList<TEntity> ToList(Func<TEntity, bool> expression)
{
return Context.CreateQuery<TEntity>("[" + EntitySetName + "]")
.Where<TEntity>(expression).ToList();
}
The expression parameter allows me to alter the result, but this is not to my expectations. Since createquery
is first evaluated and afterwards my where
is applied. I'm using this with tables with over 2 mil. records.
Does anybody have a solution how to keep the method generic, but with the abillity to control the outcome without loading all records first?