Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
LINQ To SQL: Count operator
WhatsApp
Vijai Anand Ramalingam
13y
5.8
k
0
0
25
Blog
EmpDetails Table:
Code:
To count the number of elements in the sequence.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
LINQ
{
class
Program
{
static
void
Main(
string
[] args)
{
DataClassesDataContext
dc =
new
DataClassesDataContext
();
int
empCount = (
from
emp
in
dc.EmpDetails
select
emp).Count();
Console
.WriteLine(empCount);
Console
.Read();
}
}
}
Alternate Method:
DataClassesDataContext
dc =
new
DataClassesDataContext
();
int
empCount = dc.EmpDetails.Count();
Console
.WriteLine(empCount);
Up Next
LINQ To SQL: Sum operator
Ebook Download
View all
Printing in C# Made Easy
Read by 22.3k people
Download Now!
Learn
View all
Membership not found