Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6347555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:14:19+00:00 2026-05-24T21:14:19+00:00

I have a generic repository pattern and I’m trying to load a collection of

  • 0

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:
enter image description here

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));
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:14:20+00:00Added an answer on May 24, 2026 at 9:14 pm

    There are no entity properties because the AppAgencies property on Agency is a navigational property.

    I think this is what you want:

    public IEnumerable<Agency> GetAllEnabledAgencies(int applicationId)
    {
        return _agencyRepository.GetMany(x => x.AppAgencies.Any(y => y.IsEnabled));
    }
    

    In English:

    Get all Agencies, where at least one AppAgency is enabled.

    If you want:

    Get all Agencies, where all AppAgency is enabled.

    Change Any to All.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a repository pattern setup using NHibernate. The base class looks like this:
I am using Entity Framework with the generic repository pattern. I have used the
I have the following POCO Class with its Repository Pattern Implementation. If my model
I have implemented the repository pattern using the following generic interface. public interface IRepository<T>
I have a generic Repository<T> class I want to use with an ObjectDataSource. Repository<T>
I have a repository class that inherits from a generic implementation: public namespace RepositoryImplementation
I have generic type that looks like: public class GenericClass<T, U> where T :
I have a generic class that I'm trying to implement implicit type casting for.
I have implemented a repository pattern in my asp.net mvc web application... But i
All I am trying to find out the correct definition of the repository pattern.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.