user735627
user735627

Reputation: 281

Linq query to get count

id | IsEnquiry  | 
=================
1      true
2      false
3      false
4      true

How can I get the count of id where IsEnquiry=true by using a Linq Query

Pls Help me to write the query.

Thanks, Bharath

Upvotes: 18

Views: 70158

Answers (4)

Pranav Labhe
Pranav Labhe

Reputation: 1953

Try this :

int count = (from row in db.Table
             where row.IsEnquiry == true
             select row.id).Count();

Upvotes: -1

shebin c babu
shebin c babu

Reputation: 1157

Try this code:

int count = (from tableObj in TableName 
             where tableObj
             .Website == "http://mywebsite.com" 
             select tableObj 
             .Website).Count()

Upvotes: 0

Maged Samaan
Maged Samaan

Reputation: 1752

try this

var count = db.Table.Where(x=>x.IsEnquiry).Count()

Upvotes: 26

Jared Harding
Jared Harding

Reputation: 4972

int count = (from row in db.Table
             where row.IsEnquiry == true
             select row).Count();

Upvotes: 42

Related Questions