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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:08:47+00:00 2026-05-26T07:08:47+00:00

ORMs often map one-to-many relationships such as: class Parent { IList<Child> Children { get;

  • 0

ORMs often map one-to-many relationships such as:

class Parent {
   IList<Child> Children { get; set; }
}

The problem is that in the repository, you may have:

GetChildrenOfParent(int parentID) {
   from c in Children...

   return children;
}

You now have two places to “get” children. When you want to add something, such as maybe only return children who do not have a deleted flag, you might have:

GetChildrenOfParent(int parentID) {
    from c in Children..
    where not deleted

    return children;
}

or

class Parent {
   IList<Child> Children { get .... only get not deleted children; set; }
}

Do you see what I am getting at? You now have two places in which to choose to perform the getter routine. It seems that the logical place to have this routine is in the repository, yet that means that:

foreach (var child in parent.Children)

is not going through your “getter” anymore, hence the whole idea of the ORM having one-to-many mapped this way seems to be wrong?

  • 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-26T07:08:47+00:00Added an answer on May 26, 2026 at 7:08 am

    I’m not really sure what your question is but I don’t really see where it is ‘wrong’. It comes down to design choice IMO. Do you want to access hierarchical data (child entities) from each entity. If you do and you want to load that data in on an initial fetch then utilising the one to many is a time saver (you can opt to pre load it or lazy load it). In that case fetching your data in the first example may be a good for you. You can use LINQ to filter the data to only bring back ‘non deleted’ results or ‘whatever filter you need’ like so:

    IList<Child> list = parent.Children.Where(x => x.Deleted == false);
    

    Personally, I like to keep it clean and, when I’m using the repository pattern (I’m becoming a big fan of the ActiveRecord Pattern lately). I prefer to seperate this out into it’s own method call. You could add the repository call into a property name children but then, for me, that feels like I’m crossing boundaries between have a model and where I’m hyrdating that model.

    But doing it that way sometimes ends you up with a whole bunch of methods to do basic filtering or a silly bunch or overloads to manage cases where you want to select say ‘Deleted Or Not’ and ‘Male Or Female’ or just ‘Deleted Or Not’.

    As I said, it comes down to choice. How do you want your app to grow, if you think you are ending up with a list of silly overloads in a repository can you make it cleaner so that future coders can understand your code, there’s less code to manage, and it doesn’t interfere with performance (or makes it perform better ideally). In which case having tests will help you refactor without breaking code.

    Don’t get hung up on the ‘right’ or ‘wrong’ way of doing things.

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

Sidebar

Related Questions

I often hear people bashing ORMs for being inflexible and a leaky abstraction, but
I'm new to the world of ORMs/ODMs. The word 'persistence' is used often. What
I was reading about ORMs and one of the descriptions I read said that
suppose a PHP object is associated with another (one-to-one,many-to-many,etc), what is the best way
Are there any good performance benchmarks published out there for available PHP ORMs, such
This question was inspired by one I asked almost a year ago - any-orms-that-work-with-ms-access-for-prototyping
Most common ORMs implement persistence by reachability, either as the default object graph change
Historically I've been completely against using ORMS for all but the most basics applications.
In a recent discussion on ORMs for webapps someone mentioned that there are times
What is the meaning of Unit of Work concept in NHibernate and other ORMs?

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.