473,509 Members | 3,095 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.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 2077
On Sep 19, 5:01*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 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 <tablein database select <items>) .count();

</code>

should work.
Sep 19 '08 #2

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

Similar topics

2
1540
by: SC | last post by:
Having inherited an NHibernate-based website, I'm not sold on OR/M mapping tools for largest sites - from what I've seen, even "tuned" nhiberate queries result in poor performance and I haven't...
1
1332
by: Bob Johnson | last post by:
Just wondering if LINQ might be useful and appropriate in the following scenario: I'm writing a Windows Forms app that enables the user to search for a "client account". The client account is...
14
21725
by: Ralf Rottmann \(www.24100.net\) | last post by:
I recently stumbled across a pretty interesting LINQ to SQL question and wonder, whether anybody might have an answer. (I'm doing quite some increasing LINQ evangelism down here in Germany.). ...
0
1799
by: =?ISO-8859-1?Q?S=F8ren_Reinke?= | last post by:
Hi there. I am trying to get to know LINQ in combination with a bindingsource and a datagridview. In the framework we have at work we have created a usercontrol to do filtering via...
8
46858
by: Andy | last post by:
Hi, I'm trying to add a where clause to my query: List<stringtypes = new List<string>(); types.Add( "A" ); types.Add( "B" ); query = query.Where( c =types.Contains( c.Type ) );
3
2884
by: Leo Seccia | last post by:
Hello everyone, I have a c# project with a sql server database. I have a number of lookup tables in my database which I successfully managed to import into my LINQ dataclasses. eg. Table:...
1
1504
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 the set ? var query = from row in...
21
4325
by: hrishy | last post by:
Hi Will LINQ be ported to Python ? regards Hrishy
2
3748
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
7234
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7136
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7412
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4730
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3216
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
441
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.