I have been searching on internet to find out the difference between Func and Expression Func, somehow i got the point,the first one is just a function gets the data and then apply the function in memory but the second,translate it to sql and run it in the database,after i run this two queries:
public IEnumerable<T> SelectAll(Expression< Func<T, bool>> predicate)
{
return table.Where(predicate).ToList();
}
public IEnumerable<T> SelectAll(Func<T, bool> predicate)
{
return table.Where(predicate).ToList();
}
i put the breakpoint on return,for first one it returns 12 rows,for second it returns 1200 row,the predicate is :
s=>s.id="12345"
the second one,apply the predicate after it get the data,my question is,we usualy should use the expression func when we deal with DB?
Where
methods - fromQueryable
and fromEnumerable
. – Dysgenic