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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:45:05+00:00 2026-06-18T07:45:05+00:00

Lets say we have an Entity class that has many fields and methods but

  • 0

Lets say we have an Entity class that has many fields and methods but also has a Component object. We have kept Component data encapsulated in a separate class for an arbitrary reason.

    public class Entity
    {
            //...other stuff

            public virtual Component Component { get; protected set; }

            //...other stuff
    }

Lets say our Component has many responsibilities but only 3 fields all of which are private fields. We have kept the fields private for an arbitrary reason.

    public class Component
    {
         //...other stuff

         private string fieldName1 { get; set; }
         private string fieldName2 { get; set; }
         private string fieldName3 { get; set; }

         //...other stuff
    }

Now, lets say that our Entity corresponds with a Table in the database.
We want that table to have a column for each field on the Component.
We call them “columnName1”, “columnName2”, and “columnName3” respectively.

The question is:
how can we use Fluent NHibernate to perpetuate private field data from a Component object which belongs to an Entity (that corresponds with a table in your database)?

  • 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-18T07:45:07+00:00Added an answer on June 18, 2026 at 7:45 am

    You override the auto mapping for your entity like this:

    using FluentNHibernate.Automapping.Alterations;
    
    public class EntityOverride : IAutoMappingOverride<Entity>
    {
        public void Override(AutoMapping<Entity> mapping)
        {
             mapping.Component(x => x.Component, c => 
             {
                   c.Map(Reveal.Member<Component>("fieldName1"),"columnName1");
                   c.Map(Reveal.Member<Component>("fieldName2"),"columnName2");
                   c.Map(Reveal.Member<Component>("fieldName3"),"columnName3");
             });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say thay I have an entity with name A.It has two columns named
Let's say we have an entity that has attributes att1 and att2, where att1
Let's say I have a base class named Entity . In that class, I
I have many to one relation, let's say User has a Company. Company entity
Let's say I have a product class that has a Category property on it.
Let's say I have this entity (for Hibernate): @Entity public class Person { @Id
Let's say I have the typical entity Car class Car : Entity { public
I have a question regarding foreign key in entity framework(EF4). Lets say i have
Lets say have this immutable record type: public class Record { public Record(int x,
I have a table that has two different many-to-many relations to two different tables.

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.