473,667 Members | 2,798 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.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

Sep 19 '08 #1
1 2085
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<stri ng>("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.
Sep 19 '08 #2

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

Similar topics

2
1546
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 seen them scale well - just one person's experience. Has anyone used the new Linq technology on a database contained hundred of thousands / millions of rows - can you tune Linq to retrieve data from tuned/optimized sql queries? Just trying to...
1
1339
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 made up of a client number, plus a case number. A given client can have many cases. Here are two clients - the first of which has two cases. 1234-897 1234-989 7654-232
14
21761
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.). Assume I want to select rows from a database and check whether a specific column contains keywords from a list of keywords. The following works just fine: List<stringsearchTerms = new List<string>() { "Maria", "Pedro" };
0
1812
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 textboxes on a datagridview. Therefore we databind through a bindingsource. But when i load the data from the database via LINQ instead of through a
8
46867
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
2898
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: tlkpColor (PK) tlkpColorID
1
1522
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 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"),
21
4351
by: hrishy | last post by:
Hi Will LINQ be ported to Python ? regards Hrishy
2
3753
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
8458
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8366
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8650
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6206
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5677
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4202
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.