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.
InverseonHasManyis an NHibernate term, and it means that the other end of the relationship is responsible for saving.Cascade.AllonHasManyToManytells NHibernate to cascade events down to the entities in the collection (so when you save theStore, all theProducts are saved too).Tablesets the many-to-many join table name.
https://github.com/jagregory/fluent-nhibernate/wiki/Database-configuration
作者:石世特
出处:http://www.cnblogs.com/TivonStone/
希望本文对你有所帮助,想转随便转,心情好的话给我的文章留个链接.o(. .)o

浙公网安备 33010602011771号