I have a generic repository pattern and I’m trying to load a collection of Agencies based the FkApplicationId and if it IsEnabled == true
My model looks something like this:

I thought this would be easy but I can’t create a where clause to filter the results. I can’t see the properties of the AppAgencies to write a condition, this is as far as I can get:
public IEnumerable<Agency> GetAllEnabledAgencies(int applicationId)
{
return _agencyRepository.GetMany(m => m.AppAgencies.//No Entity Properties are here);
}
From my repository base which is called from above:
public virtual IEnumerable<T> GetMany(Expression<Func<T, bool>> where)
{
return _dbSet.Where(where).ToList();
}
Thanks RPM1984, Solution:
Agencies are consumed by multiple applications, and they need the ability to enable/disable each one per application. So I was using the AppAgency table to tie together that req. because I don’t want to have to add a new column to the Agency entity every time a new application is introduced.
public IEnumerable<Agency> GetAllEnabledAgencies(int applicationId)
{
return _agencyRepository.GetMany(x => x.AppAgencies.Any(y => y.IsEnabled && y.FkApplicationId == applicationId));
}
There are no entity properties because the
AppAgenciesproperty onAgencyis a navigational property.I think this is what you want:
In English:
If you want:
Change
AnytoAll.