需要帮助将此映射文件从 NHibernate 转换为 Fluent NHibernate

发布于 2024-09-09 03:51:58 字数 1471 浏览 4 评论 0原文

我想将此映射文件从 NHibernate 转换为 Fluent NHibernate

    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
      <class name="CustomCollectionsBasic.Core.Category, CustomCollectionsBasic.Core" table="Categories">
        <id name="ID" column="CategoryID" unsaved-value="0">
          <generator class="identity" />
        </id>
    <property name="Name" column="CategoryName" />

    <bag name="ProductsInCategory" table="Products" cascade="all" inverse="true"
         collection-type="CustomCollectionsBasic.Data.Collections.PersistentProductsType, CustomCollectionsBasic.Data">
     <key column="CategoryID" />
     <one-to-many class="CustomCollectionsBasic.Core.Product,ustomCollectionsBasic.Core" />
    </bag>
  </class>
</hibernate-mapping>

我尝试通过 NHibernateHbmToFluent 转换它,结果是

public class CategoryMap: ClassMap<CustomCollectionsBasic.Core.Category>
{
    public CategoryMap()
    {
        Table("Categories");
        Id(x => x.ID)
            .GeneratedBy.
            .UnsavedValue(0);
        Map(x => x.Name, "CategoryName");
        HasMany<CustomCollectionsBasic.Core.Product>(x => x.ProductsInCategory)
            .AsBag()
            .KeyColumn("CategoryID")
            .Table("Products")
            .Inverse()
            .Cascade;
    }
}

但它不起作用。

关于如何绘制此图有什么想法吗?

提前致谢。

i want to convert this mapping file from NHibernate to Fluent NHibernate

    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
      <class name="CustomCollectionsBasic.Core.Category, CustomCollectionsBasic.Core" table="Categories">
        <id name="ID" column="CategoryID" unsaved-value="0">
          <generator class="identity" />
        </id>
    <property name="Name" column="CategoryName" />

    <bag name="ProductsInCategory" table="Products" cascade="all" inverse="true"
         collection-type="CustomCollectionsBasic.Data.Collections.PersistentProductsType, CustomCollectionsBasic.Data">
     <key column="CategoryID" />
     <one-to-many class="CustomCollectionsBasic.Core.Product,ustomCollectionsBasic.Core" />
    </bag>
  </class>
</hibernate-mapping>

I try to convert it by NHibernateHbmToFluent and the result is

public class CategoryMap: ClassMap<CustomCollectionsBasic.Core.Category>
{
    public CategoryMap()
    {
        Table("Categories");
        Id(x => x.ID)
            .GeneratedBy.
            .UnsavedValue(0);
        Map(x => x.Name, "CategoryName");
        HasMany<CustomCollectionsBasic.Core.Product>(x => x.ProductsInCategory)
            .AsBag()
            .KeyColumn("CategoryID")
            .Table("Products")
            .Inverse()
            .Cascade;
    }
}

but it not working.

Any ideas on how to map this?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝咒 2024-09-16 03:51:58
    Id(x => x.ID)
        .GeneratedBy
        .Identity()
        .UnsavedValue(0);

我觉得其他的都还好

    Id(x => x.ID)
        .GeneratedBy
        .Identity()
        .UnsavedValue(0);

I think the other stuff is OK

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文