I have two tables (Application and Hazard) with a one to many relationship.
I want to store the list of Hazards to a List object in my ViewModel.
applicationVm (greatly simplified to just show the collection):
...
public List<Hazard> Hazards { get; set; }
LINQ query (greatly simplified to just show the collection):
IQueryable<ApplicationVm> applVms;
applVms = from app in _db.Applications
...
join hz in _db.Hazards on app.Id equals hz.ApplicationId into hzr
from hzrd in hzr.DefaultIfEmpty()
select new ApplicationVm { ..., Hazards = hzrd };
Intellisense shows the error 'cannot covert source type Hazard to target type List<Hazard>
' on the Hazards = hzrd in the select.
How do I write this LINQ query.
PS I do not want to return applVms as a list since I'm lazy loading.