views:

192

answers:

1

Hi all,

I am using Linq to entities and would like to know if I can get a limited number of records when i query. I just need the top N records as the query do the orderby and other clauses. Is this possible or I will have to get the top N using foreach loop?

Thanks in advance for Ideas and suggestions,
Abdel Olakara

+5  A: 

You can just use the .Take method call to get a couple of result. You can read more on this topic here.

You need to understand that the query will not be executed unless someone executes the GetEnumerator().

sovanesyan