How do I get the number of rows in the set(linq)

T

Tony Johansson

Hello!

If I for example have this set names query or some other set which has been
returned by using linq how
do I get the number of rows in th set ?


var query = from row in table1.AsEnumerable()
join bar in doc.Root.Elements("bar")
on row.Field<int>("k") equals
(int)bar.Attribute("k")
select new { key = row.Field<int>("k"),
foo = row.Field<string>("foo"), bar =
(string)bar.Attribute("bar") };

//Tony
 
D

Duggi

Hello!

If I for example have this set names query or some other set which has been
returned by using linq how
do I get the number of rows in th set ?

var query = from row in table1.AsEnumerable()
                         join bar in doc.Root.Elements("bar")
                         on  row.Field<int>("k") equals
(int)bar.Attribute("k")
                         select new { key = row.Field<int>("k"),
                         foo =  row.Field<string>("foo"), bar =
(string)bar.Attribute("bar") };

//Tony

int i = ( from row in table1.AsEnumerable()
join bar in doc.Root.Elements("bar")
on row.Field<int>("k") equals
(int)bar.Attribute("k")
select new { key = row.Field<int>("k"),
foo = row.Field<string>("foo"), bar =
(string)bar.Attribute("bar") }).Count();

<code>

int count = (From <table> in database select <items>) .count();

</code>

should work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top