Inverse.Cascade.All.Table

image

public class StoreMap : ClassMap<Store>
{
  public StoreMap()
  {
    Id(x => x.Id);
    Map(x => x.Name);
    HasMany(x => x.Staff)
      .Inverse()
      .Cascade.All();
    HasManyToMany(x => x.Products)
     .Cascade.All()
     .Table("StoreProduct");
  }
}

You've also just got your first taste of the fluent interface Fluent NHibernate provides. The HasMany method has a second call directly from it's return type (Inverse()), and HasManyToMany has Cascade.All() and Table; this is called method chaining, and it's used to create a more natural language in your configuration.

  • Inverse on HasMany is an NHibernate term, and it means that the other end of the relationship is responsible for saving.
  • Cascade.All on HasManyToMany tells NHibernate to cascade events down to the entities in the collection (so when you save the Store, all the Products are saved too).
  • Table sets the many-to-many join table name.

https://github.com/jagregory/fluent-nhibernate/wiki/Database-configuration
原文地址:https://www.cnblogs.com/TivonStone/p/2761620.html