Thanks Viktor. I went ahead with the suggested approach and that worked get for that issue. My issue now is if there is a subquery that uses a scalar database function. For the below query I get a NotImplementedException since the child query is not loaded initially. Is there a way to have this work?
return (from f in dbContext.Fundraisers
let totalRaised = EntitiesModel.CFKCDB.GetTotalRaisedForFundraiser(f.FundraiserID)
where f.Status == 'A'
select new ViewModels.Site.FundraiserSummary
FundraiserID = f.FundraiserID,
CustomURL = f.CustomURL,
EventType = f.EventID.HasValue ? f.Event.EventType.TypeName : "",
FundraiserTypeID = f.FundraiserTypeID,
Name = f.Name,
IsFeatured = f.IsFeatured,
TotalRaised = totalRaised,
Fundraisers = (from c in f.Fundraisers
let childTotalRaised = EntitiesModel.CFKCDB.GetTotalRaisedForFundraiser(c.FundraiserID)
where c.Status == 'A'
select new ViewModels.Site.FundraiserDetailChildSummary
FundraiserID = c.FundraiserID,
EventType = c.EventID.HasValue ? c.Event.EventType.TypeName : "",
FundraiserTypeID = c.FundraiserTypeID,
Name = c.Name,
CustomURL = c.CustomURL,
AllowChildren = c.AllowChildren,
TotalRaised = childTotalRaised