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 st开发者_如何学Goring 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.
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/
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论