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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:56:22+00:00 2026-05-22T02:56:22+00:00

I have a standard repository interface in C# which includes the following methods: IEnumerable<T>

  • 0

I have a standard repository interface in C# which includes the following methods:

IEnumerable<T> GetAll();
T GetById(int id);
void Delete(T entity);
void Add(T entity);

At my domain layer all I am instantiating is a new Unit of Work wrapper and passing it to a repository. The Unit of Work wrapper class hides whether I’m using NHibernate or Entity Framework and exposes a Commit() method.

In my domain layer, how can I query for objects which meet only a particular criteria?

I think what I’m doing at the moment is terribly inefficient. I am currently doing this:

var results = myRepository.GetAll().Where......

If I have a very large amount of objects, is GetAll() going to return every one of them before filtering out the ones I don’t need? How can I prevent unwanted object from being returned at all?

Obviously I could add more methods to the interface, but this doesn’t seem in keeping with exposing only CRUD operations via the interface.

i.e. – I don’t think I should be adding things like (but maybe I’m wrong):

IList<T> GetAllWhereMeetsMyCriteria();
  • 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-22T02:56:22+00:00Added an answer on May 22, 2026 at 2:56 am

    Have a look at the repository pattern used in this blog post [weblogs.asp.net]. I have found the source code to employ a few interesting patterns that I keep returning back to and checking again. The code implements both repository and unit of work patterns.

    To answer your specific question, the repository interface contains the method:

    IEnumerable<T> GetMany(Expression<Func<T, bool>> where);    
    

    It is implemented as follows in the RepositoryBase<T> class:

    public virtual IEnumerable<T> GetMany(Expression<Func<T, bool>> where)
    {
        return dbset.Where(where).ToList();
    }
    

    Probably both EF and NHibarnate will have the interfaces necessary to support this usage.

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

Sidebar

Related Questions

I have a directory structure in my SVN repository which is pretty standard: /project1
I have a pretty standard Repository pattern going, where repositories are injected into my
Currently we have a project with a standard subversion repository layout of: ./trunk ./branches
I have a subversion repository with the standard layout, i.e. trunk/ and branches/ (and
I have a remote server that hosts my subversion repository on a non-standard ssh
In many projects, I check out the complete repository and have then the standard
I have two projects in the same Subversion repository. They both use some standard
I have what I'd consider a standard .NET MVC3 Repository pattern project that I've
In my subversion repository, I have the standard /trunk , /branches and /tags folders
Many languages have standard repositories where people donate useful libraries that they want others

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.