2

Take a query

dim q = from i in db.test select i.name

Now I use count to get the complete number of the items. I use them to get a pager control:

dim count = q.count

Then I use take and skip to get my records.

This produces two queries and I wonder if there is a possibility to get the count of all items but to select only 10 of them so that l2s produces just one query.

The columns would then look like:

allcount - name

This query would give me 10 items, but in the column allcount would be the complete number of all items.

Jakub Hampl
  • 39,863
  • 10
  • 77
  • 106
Luke
  • 8,235
  • 3
  • 22
  • 36

1 Answers1

0

try using 'new' statement; it always works for me :)

var _data = from i in db.test select new { count = i.name.count(), records = i.name };

You can also see my blog on basic LINQ to SQL queries: LinqtoSQL

Hope it helps!

casper123
  • 1,736
  • 4
  • 21
  • 39
  • i know the new statement, but if you read my question again, maybe you will see that this absolutly will not solve the problem – Luke Jun 18 '11 at 02:36