实体上与 nhibernate 的多对多关系
我有一个 nhibernate 问题,
我有一个包含多对多关系的 hbm 文件。 到目前为止,这是有效的,但我想从实体生成 hbm
并尝试在实体上设置属性,但这不会编译
这是 hbm 文件
<list name="Category" table="Category" lazy="false" fetch="select" cascade="none">
<key column="categoryId" />
<index column="ordinal" />
<many-to-many class="Product, Assembly" column="productId" />
</list>
,现在已在实体上执行此操作
[List(2, Name = "Product", Table = "Product", Cascade = CascadeStyle.None, Lazy = false, Fetch = CollectionFetchMode.Select)]
[ManyToMany(5, ClassType = typeof(Product), Column = "productId")]
public virtual IList<Category> Categorys
I have a problem with nhibernate,
i have a hbm file with a many to many relations.
This works so far but i want to generate the hbm from a entity
and trying to set the properties on the entity but that will not compile
this is the hbm file
<list name="Category" table="Category" lazy="false" fetch="select" cascade="none">
<key column="categoryId" />
<index column="ordinal" />
<many-to-many class="Product, Assembly" column="productId" />
</list>
and have did now on the entity
[List(2, Name = "Product", Table = "Product", Cascade = CascadeStyle.None, Lazy = false, Fetch = CollectionFetchMode.Select)]
[ManyToMany(5, ClassType = typeof(Product), Column = "productId")]
public virtual IList<Category> Categorys
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您忘记了实体上的序号和键
试试这个
You forgot the ordinal and the key on the entity
try this