473,322 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

how do I get the number of rows in a linq set

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 the 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

Sep 19 '08 #1
1 1500
On Sep 19, 5:02*pm, "Tony Johansson" <t.johans...@logica.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 the 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 count = (From <tablein database select <items>) .count();

should work,...

Thanks
-Cnu
Sep 19 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: sysmanint1 | last post by:
I am a total neophyte at Visual Basic but found the following post and reply from Clint concerning a dynamic range. Also, have never "posted" to a discussion I have made a macro that works on...
4
by: Lacutas | last post by:
Hi all, I am having some problems using LINQ to access Distinct records from a Dataset. I have looked around and believe it should be as simple as added .Distinct() to my LINQ query below, though...
9
by: =?Utf-8?B?cmF1bGF2aQ==?= | last post by:
Hi all: after reading different places/sites about linq... I ran into these questions: 1. What framework do we need to run linq ? (does it depend on what version of visual studio we have?) how...
0
by: =?Utf-8?B?SHlwZXJjb2Rlcg==?= | last post by:
I'm encountering some strange behavior after deploying a ASP.net 3.5 website to production, i'm unable to reproduce these in my dev environment. This error seems to occur very randomly but it's...
1
by: Tony Johansson | last post by:
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...
1
by: CAM | last post by:
Hello, I am using Visual Basic.Net 2008. In my form I have database file connected to SQL 2008 Express. I want to have a text box where I can type in the policy number and I will get the...
3
by: =?Utf-8?B?UGF1bCBQcmV3ZXR0?= | last post by:
I'm attempting to use LINQ to insert a record into a child table and I'm receiving a "Specified cast is not valid" error that has something to do w/ the keys involved. The stack trace is: ...
2
by: Andy B | last post by:
How would you find out if a linq table has 0 rows in it? I have this code: NewsContext.V_News() '*** linq table to be tested for 0 rows Any ideas?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.