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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:39:07+00:00 2026-05-23T18:39:07+00:00

I have a collection of objects like this public class ApplicationConfiguration { public virtual

  • 0

I have a collection of objects like this

public class ApplicationConfiguration
{
    public virtual long ApplicationConfigurationId { get; set; }
    public virtual Site Site { get; set; }

    public virtual ApplicationParameters ApplicationParameters { get; set; }
    public virtual IList<ApplicationParameters> ApplicationParametersHistory { get; set; }
}

public class ApplicationParameters
{
    public virtual int ApplicationParametersId { get; set; }
    public virtual Site Site { get; set; }
    public virtual int Status { get; set; }
}

public class Site
{
    public virtual int SiteId { get; set; }
}

The way I want my model to work is that they are all bound together by my site object. My business logic ensures that one ApplicationParameters is “active” and the rest are held within the History collection.

My problem comes when mapping these together with Fluent. I have something like this

public class ApplicationConfigurationMap : ClassMap<ApplicationConfiguration>
{
    public ApplicationConfigurationMap()
    {
        Table("MerchantApplicationConfigurations");

        Id(x => x.ApplicationConfigurationId, "MerchantApplicationConfigurationId").GeneratedBy.Identity();

        References<Site>(x => x.Site, "SiteId");

        References<ApplicationParameters>(x => x.ApplicationParameters, "ApplicationParametersId");
    }
}

But, how do I map my collection to pick up all the ApplicationParameters with Status 4 where the siblings have the same SiteId? I know I can use .Where("Status = 4") but the rest of the mapping I’m not sure about.

EDIT

I need to clarify my design a bit.

A site is an external object used in legacy systems, so I cant alter it. When creating these applications (a paper application, not a software application), I have to retain a complete history of all changes. I broke the application out into a bunch of different pieces, and this configuration object is the base for the side of the application that we configure (pricing, fees, etc).

The way this system is going to work is that every part can be edited, and when it is, I create a new record with an active status and then the previous item(s) with a non-historical status are set to historical. This way, only one record for each site is active at a given time.

I am pulling my data back by site, because I can always select the active components for that site. If I bind my application pieces to the ApplicationConfiguration it means the base object can no longer follow my historical preservation model. I also want to avoid pulling back all the pieces separately and building a DTO.

I didn’t want to attach everything to the Site object because it’s used in other applications that share this codebase. This data model is used only within an administration application, so I wanted to keep it separate from the Site object, which is used in the admin and client applications.

  • 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-23T18:39:08+00:00Added an answer on May 23, 2026 at 6:39 pm

    In NHibernate, when mapping a collection of entities, you have to provide a key column in the collection table that references back to the parent table. .Where("") just provides additional filtering on top of that.

    In your case, if a list of ApplicationParameters belongs to ApplicationConfiguration then it should have ApplicationConfigurationId column.

    If you need to tie objects through SiteId then you should move ApplicationParametersHistory to the Site entity.

    Now your model is represented differently in your classes and in your DB. So, if you are able to reorganize your model a bit then you can use the standard way of mapping.

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

Sidebar

Related Questions

I have a collection of country objects that look like this: class country {
Say I have a class like this: public class MyClass { public string Name;
I have a collection of objects that look like this: List<MyObject> objects = new
I have a collection of objects like so: public enum ObjectType { Type1, Type2
Let's say that I have classes like this: public class Parent { public int
I have a collection of class objects: Tests This collection contains many Test instances:
I have a large (more than 100K objects) collection of Java objects like below.
I have a collection of objects to which I'd like to just add a
I'm trying to build an object that looks something like this: public class MyObject
I have a collection of objects of one type that I'd like to convert

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.