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 7714041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:01:30+00:00 2026-06-01T02:01:30+00:00

I have the following generic repository: public class GenericRepository<TEntity> where TEntity : class {

  • 0

I have the following generic repository:

public class GenericRepository<TEntity> where TEntity : class {
    private EFDbContext context;
    private DbSet<TEntity> dbSet;

    public GenericRepository(EFDbContext context) {}

    public IEnumerable<TEntity> GetAll() {}

    public IEnumerable<TEntity> Get(Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, string includeProperties = "") {}

    public TEntity GetByID(int id) {}

    public void Insert(TEntity entity) {}

    public void Delete(int id) {}

    public void Delete(TEntity entity) {}

    public void Update(TEntity entity) {}
}    

Now I understand how I can use this for my entities, but I don’t understand what to do if an entity needs more than just these methods? Say I have an entity called ‘Tournament’ and I want to get all the groups in that tournament, where would the ‘GetTournamentGroups’ method go?

Should I, instead of using a generic repository, write a basic repository interface which all the entities’ own interfaces inherit from and then just add the additional methods needed for each entity?

  • 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-06-01T02:01:32+00:00Added an answer on June 1, 2026 at 2:01 am

    Method GetTournamentGroups() seems to belong to the layer above Repository layer:

    class TournamentModel
    {
        private int tournamentId;  // initialized in constructor
        private GenericRepository<Group> repository;  // initialized in constructor
    
        IEnumerable<Group> GetTournamentGroups()
        {
            return repository.Get( group => group.TournamentId == tournamentId);
        }
    }
    

    I’d recommend using IQueryable insteam of IEnumerable in your GenericRepository, though. It would be more flexible if you need to apply filters or sort expressions before you make an actual database query.

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

Sidebar

Related Questions

If i have the following IQueryable<T> Repository: public class OrderRepository : GenericRepository<Order>, IOrderRepository {
Let's say I have a Generic Repository class along the lines of the following:
Say I have the following generic class: public class Foo<T extends Bar> { //
Suppose you have the following Generic class heirarchy: public abstract class GenericBase<T> { T
I have implemented the repository pattern using the following generic interface. public interface IRepository<T>
I have the following model structure: class Container(models.Model): pass class Generic(models.Model): name = models.CharacterField(unique=True)
I have some generic types, like the following: public struct Tuple<T1, T2> { ...
I have a class similar to the following: public abstract class Manager<T, TInterface> :
I have the following code: private int AllFeb(Forecast f, IRepository repository) { return All(f,
I have this generic method in my repository: public T GetFirstOrDefault(Expression<Func<T, bool>> where, Expression<Func<T,

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.