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

  • Home
  • SEARCH
  • 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 6337169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:12:06+00:00 2026-05-24T19:12:06+00:00

So I will call a repository to retrieve the root object of a complex

  • 0

So I will call a repository to retrieve the root object of a complex object graph, using FluentNHibernate. But for some sub-level objects I don’t want to retrieve all elements, but only those where a date parameter equals certain condition. In below code, I want the lower level Order object to be filtered in this way by the OrderTime field.

Meaning I want to retrieve all UserGroups, with all Users, but the Orders object of each User shall only contain orders from a specific date or date range.

So what are my options on how to retrieve this object graph? I don’t want lazy loading, I just want to specify a handful of different retrieval conditions, which will never change. So they can be separate functions of the repository, like suggested at the end. But how would I go about coding those methods, how to specify these conditions?

Objects:

public class UserGroup
{
    public int Id;
    public IList<User> Users;
}

public class User
{
    public int Id;
    public string Name;
    public IList<Order> Orders;
}

public class Order
{
    public int Id;
    public decimal Price;
    public System.DateTime OrderTime;
}

Repository:

public class UserGroupRepository
{    
    public List<UserGroup> GetAll()
    {
        using (ISession session = FNH_Manager.OpenSession()) {
            dynamic obj = session.CreateCriteria(typeof(UserGroup)).List<UserGroup>();
            return obj;
        }
    }
}

Potential new Repository methods: ?

public List<UserGroup> GetAll_FilterOrderDate(System.DateTime _date)
{
}

public List<UserGroup> GetAll_FilterOrderDate(List<System.DateTime> _dates)
{
}
  • 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-24T19:12:08+00:00Added an answer on May 24, 2026 at 7:12 pm

    It really depends on what you want to do with the orders.

    Is there a reason you need to query on the aggregate root? Would it make sense to query over the actual orders by date instead? So you’d end up with:

    session.QueryOver<Order>().Where(t => t.OrderDate > ...);
    

    If your associations are set up correctly you’ll still be able to navigate to the user.

    Personally I find the repository pattern to be a bit restrictive and would rather use query objects, so you’d end up with something like:

    queryService.FindAll<UserGroup>(new GetAllByFilterOrderDate(DateTime.Now));
    

    However if the concept of a repository works for you then by all means stick to it, but it means you’ll try to force your object model into this ‘UserGroup’ centric view.

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

Sidebar

Related Questions

I have a datagridview which we will call dataGridViewExample. My object (the uncommon datatypes
I have DLL and application that will call some function in this dll. For
I want to have an executable file that will call some other programs. The
I have set up a Maven 2 repository (call 'dev repository') using Apache Archiva
I have a user on what we will call PageA.aspx. This user needs to
I have a Batch file which will call a Powershell Script : BATCH FILE
I have a file we will call info.txt under UNIX format that has only
If I use assert() and the assertion fails then assert() will call abort() ,
I have a button on an ASP.Net page that will call Response.Redirect back to
My objective is to write a program which will call another executable on a

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.