Linq Count with Condition
Just add a predicate to your Count()
expression (and don't forget to include System.Linq
):
var recordCount = ctx.Cases.Count(a => a.Role == "admin");
First give Where and then count.
ctx.Cases.Where(c => your condition).Count();
var recordCount = ctx.Cases.Count(a => a.Role == "admin" && a.Userid="userid");