tags:

views:

39

answers:

3

Does Take(N) executes after getting full list or the execution stope after picking the needed top n records

Thanks..

A: 
this
  .Where(t +> t.Something == 1)
  .Take(5)

Will take the first 5 elements satisfying condition. It will NOT return the whole data set.

Take runs after the deferred execution.

Kindness,

Dan

Daniel Elliott
+2  A: 

Take(n) will translate into a Top on older versions of SQL server and ROW_NUMBER on newer versions on the SQL side, if that is what you are asking.

Robban
+1  A: 

According to Scott Guthrie LINQ2SQL uses the ROW_NUMBER function in SQL Server to implement the Take(n) method. So it's done by the database and not by the client on the full result set.

Joey