I have the following linq to sql:
int someNumber = (from a in TableA.col1
group a by a.DateUTC.Value.ToLocalTime().Date into g
where TableA.col2 = Emp
select g).Count();
The above works fine. But then DateUTC started accumulating null values, which breaks the query. I tried this:
int someNumber = (from a in TableA.col1
group a by a.DateUTC.Value.ToLocalTime().Date into g
where TableA.col2 = Emp && TableA.DateUTC != null
select g).Count();
But the second query isn’t filtering out nulls. I’m guessing that is because the group comes before the where. Is there some way to use the original query to avoid an except because DateUTC may have null values?
The solution would be filtering before grouping: