EDIT: Let\'s try this again. This time I\'ve used the AdventureWorks sample database so you can all play along. This will rule out anything crazy I\'ve do
Try this:
Expression> activePlanPredicate = plan => plan.CancelDate == null && plan.UpgradeDate == null;
var result = from subAccount in db.SubAccounts
select new ServiceTicket
{
MaintenancePlans = subAccount.Maintenances.Where(activePlanPredicate).Select(plan => plan.ToString()).ToArray()
// Set other properties...
};
I don't have VisualStudio in front of me, so that may require some tweaking. The issue you're running into is that you want to access the IQueryable
extension of Where
, but just having a Func
gives you the IEnumerable
extension.