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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony Johansson

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

    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.AsEnumer able()
    join bar in doc.Root.Elemen ts("bar")
    on row.Field<int>( "k") equals
    (int)bar.Attrib ute("k")
    select new { key = row.Field<int>( "k"),
    foo = row.Field<strin g>("foo"), bar =
    (string)bar.Att ribute("bar") };

    //Tony

  • Duggi

    #2
    Re: How do I get the number of rows in the set(linq)

    On Sep 19, 5:01 pm, "Tony Johansson" <t.johans...@lo gica.comwrote:
    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.AsEnumer able()
                             join bar in doc.Root.Elemen ts("bar")
                             on  row.Field<int>( "k") equals
    (int)bar.Attrib ute("k")
                             select new { key = row.Field<int>( "k"),
                             foo =  row.Field<strin g>("foo"), bar =
    (string)bar.Att ribute("bar") };
    >
    //Tony
    int i = ( from row in table1.AsEnumer able()
    join bar in doc.Root.Elemen ts("bar")
    on row.Field<int>( "k") equals
    (int)bar.Attrib ute("k")
    select new { key = row.Field<int>( "k"),
    foo = row.Field<strin g>("foo"), bar =
    (string)bar.Att ribute("bar") }).Count();

    <code>

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

    </code>

    should work.

    Comment

    Working...