This is my query:
var entityMerchantVisit =
from e in context.MerchantCustomerVisit
where e.CustomerId == currentCustGuid
group e by
new { e.Merchant.Locations.FirstOrDefault().CityId } into mcvGroup
orderby mcvGroup.Count() descending
select mcvGroup;
I'm getting error
"The cast to value type 'Int32' failed because the materialized value is null" when e.Merchant.Locations.FirstOrDefault().CityId is null.
How do I check if it's null before hand. I would like to assign it as (int) 0
, if it is null.