is there a way to select one per every 5 records in sql server with linq?
+2
A:
.Skip(5).Take(1);
If you want a more descriptive answer then please post your code.
Ian Roke
2009-05-08 21:36:13
is skip also a sql keyword?
2009-05-08 21:38:43
This selects just *one* record, the *sixth* item in the collection. I guess the OP needs one in each five.
Mehrdad Afshari
2009-05-08 21:44:53
No, skip is *not* a SQL keyword - it's one of the standard operators in the LINQ functionality ste.
marc_s
2009-05-09 08:25:58
+3
A:
I don't think it's possible to do server side directly with LINQ to SQL. There is a client side solution, however:
var result = new DataContext().Table.AsEnumerable()
.Select((x, i) => new { Index = i, Item = x })
.Where(t => t.Index % 5 == 0).Select(t => t.Item);
Mehrdad Afshari
2009-05-08 21:40:55