Complex
这是我对and的映射Dish
:
public class ComplexMapping:ClassMap<Complex>
{
public ComplexMapping()
{
Table("ComplexTable");
Id(comp => comp.Id,"ComplexId").GeneratedBy.Identity();
Map(comp => comp.Name,"Name").Not.Nullable();
Map(comp => comp.Subscribe, "DescriptionComplex");
HasManyToMany(comp => comp.ScrollOfDish)
.Table("ComplexDish")
.ParentKeyColumn("ComplexId")
.ChildKeyColumn("DishId").Cascade.All();
}
}
public class DishMapping:ClassMap<Dish>
{
public DishMapping()
{
Table("DishTable");
Id(dish => dish.Id, "DishId").GeneratedBy.Identity();
Map(dish => dish.Name);
Map(dish => dish.Description);
Map(dish => dish.Price);
References(x => x.Category, "CategoryId").Cascade.None();
HasManyToMany(comp => comp.Scroll)
.Table("ComplexDish")
.ParentKeyColumn("DishId")
.ChildKeyColumn("ComplexId").Inverse();
}
}
我使用 DAO 模式——当来自前端的数据到来时,我创建所需的对象
对象保存但不是整个对象,仅名称和描述已保存,但产品集合未保存。我想我忘记了一些简单的事情请帮助我。