So, I have the following linq query that expires when the foreach loop enumerates data:
public IQueryable<Client> GetTopLevelData(Guid agentGuid, int year) { var clients = from client in ObjectContext.Clients join cbc in ObjectContext.Client_Bucket_Client on client.Client_GUID equals cbc.Client_GUID join acb in ObjectContext.Agent_Client_Bucket on cbc.Client_Bucket_GUID equals acb.Client_Bucket_GUID where acb.Agent_GUID == agentGuid orderby client.Last_Change_Date descending, client.File_Under select client; var clientInfos = from c in clients select new { Client = c, TransactionInfos = ObjectContext.Transactions .Where(t => t.Client_GUID == c.Client_GUID && t.Year == year) .Select(t => new { Transaction = t, ToAttach = ObjectContext.Forms.Where(f => f.Transaction_GUID == t.Transaction_GUID && f.Year == year)
source share