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
In LINQ, you can count the total number of elements present in the given sequence by using the Count Method. This method returns the total number of elements present in the given sequence.
Count() methodIEnumerable<string> strings = new List<string> { "first", "then", "and then", "finally" }; // Will return 4 int result = strings. Count(); NOTE: The Count() LINQ method (an extension method to IEnumerable<T> ) is slightly different from the Count property on List<T> .
Please use the Count() method. IQueryable<People> list = repository. FindAllPeople; int cnt = list. Count();
In LINQ, aggregation functions are those functions which are used to calculate a single value from the collection of the values.
int count = (from row in db.Table
where row.IsEnquiry == true
select row).Count();
try this
var count = db.Table.Where(x=>x.IsEnquiry).Count()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With