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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:28:52+00:00 2026-05-25T00:28:52+00:00

I have a Customer which has Addresses: public class Customer { public int Id

  • 0

I have a Customer which has Addresses:

public class Customer
{
   public int Id { get; set; }
   public string Name { get; set; }
   public ICollection<Address> Addresses { get; private set; }
}

public class Address 
{
   public string City { get; set; }
   public string Country { get; set; }
   public string StreetName { get; set; }
   public string ZipCode { get; set; }
}

I want to map this to NHibernate 3.2. which has fluent interface, but not exactly the same as well-known Fluent NHibernate.
I know that I have to use Bag, and maybe Element? Or component?
So it should be something like this:

Bag( 
   property => property.Addresses,
   collectionMapping => {}, // not important now
   mapping => // and what should I use here, and how?
  );

Thanks.

  • 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-25T00:28:52+00:00Added an answer on May 25, 2026 at 12:28 am
    public class CustomerMap : ClassMapping<Customer>
    {
        public CustomerMap()
        {
            Id(x => x.ID, map => map.Generator(Generators.HighLow,
                          gmap => gmap.Params(new {max_low = 100})));
            Property(x => x.Name,
                          map => { map.Length(150); map.NotNullable(true); });
            Bag(x => x.Addresses,
               collectionMapping =>
               {
                   collectionMapping.Table("CustomerAddresses");
                   collectionMapping.Cascade(Cascade.All);
                   collectionMapping.Key(k => k.Column("CustomerId"));
               });
        }
    }
    

    more info: http://moh-abed.com/2011/08/14/nhibernate-3-2-mapping-entities-and-value-objects-by-code/

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

Sidebar

Related Questions

I have a Customer class which has a representative field....this field is initially blank
Say I have a class Customer which has a property FirstName . Then I
I have a table called customer which has, among others, a column called name
I have a abstract class called Customer which has some attributes shared amongst all
I have a customer table, which has a field categories. It's a string holding
I have class(Customer) which holds more than 200 string variables as property. I'm using
I have a Customer object which has a collection of ContactNumbers. Is it possible
Let's say I have a Customer table which has a PrimaryContactId field and a
I have a Customer class that contains a property, MyProperty, which is of a
I have a business model called Customer which has many required properties (via DataAnnotations)

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.