I got a SQL Server table with columns ResolvedDate
and ResolvedBy
.
Now I want to select those two columns and count their results, which I
var dates = dataContext.Activities
.Where(a => a.IsResolved && a.ResolvedBy == userId)
.Select(a => a.ResolvedDate)
.ToList();
var count = dates.Count;
If you only want to get the count, you can make it much faster by selecting the count alone:
var count = dataContext.Activities
.Count(a => a.IsResolved && a.ResolvedBy == userId);