Reputation: 34297
I have a DAL method that retrieves items. The items exist in the DAL method, but not in the calling code. How is that possible?
Calling code:
IEnumerable<InstallationSummary> installationSummaryList =
InstallationSummaryLogic.GetByServerAppAndGroup(appServer, appWithValidGroup);
DAL method showing that items indeed exist:
Calling code, showing no items. Where did they go?
(This is the same line shown at the top of this question.)
The only thing in between the DAL method and the calling code is a logic class that's simply a pass-through. For completeness, I've included it here:
public static IEnumerable<InstallationSummary> GetByServerAppAndGroup(ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup)
{
return DataAccessFactory.GetDataInterface<IInstallationSummaryData>().GetByServerAppAndGroup(appServer, appWithGroup);
}
Edit - Show Entire DAL Method
public IEnumerable<InstallationSummary> GetByServerAppAndGroup(ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup)
{
IQueryable<InstallationSummary> summaries = this.Database.InstallationSummaries
.Include(x => x.ApplicationServer)
.Include(x => x.ApplicationWithOverrideVariableGroup.Application)
.Include(x => x.ApplicationWithOverrideVariableGroup.CustomVariableGroup)
.Where(x => x.ApplicationServer.IdForEf == appServer.IdForEf)
.Where(x => x.ApplicationWithOverrideVariableGroup.Application.IdForEf == appWithGroup.Application.IdForEf);
if (appWithGroup.CustomVariableGroup == null)
{
return summaries.Where(x => x.ApplicationWithOverrideVariableGroup.CustomVariableGroup == null);
}
return summaries
.Where(x =>
x.ApplicationWithOverrideVariableGroup != null &&
x.ApplicationWithOverrideVariableGroup.CustomVariableGroup != null &&
x.ApplicationWithOverrideVariableGroup.CustomVariableGroup.IdForEf == appWithGroup.CustomVariableGroup.IdForEf);
}
Upvotes: 4
Views: 185
Reputation: 1499770
Your GetByServerAppAndGroup
method filters summaries
using a Where
call (we can't see what it really is - it would be helpful if you'd cut and paste the method itself). My guess is that none of the results within summaries
passes the filter in the Where
call.
Upvotes: 6