I have a table:
-- Tag
ID | Name
-----------
1 | c#
2 | linq
3 | entity-framework
I have a class that will have the following metho
Compiled queries save you time, which would be spent generating expression trees. If the query is used often and you'll save the compiled query, you should definitely use it. I had many cases when the query parsing took more time than the actual round trip to the database.
In your case, if you are sure that it would generate SELECT ID, Name FROM Tag
without the WHERE
case (which I doubt, as your AllQueries
function should return IQueryable
and the actual query should be made only after calling ToList
) - you shouldn't use it.
As someone already mentioned, on bigger tables SELECT * FROM [someBigTable]
would take very long and you'll spend even more time filtering that on the client side. So you should make sure that your filtering is made on the database side, no matter if you are using compiled queries or not.