开发者

need help to convert this mapping file from NHibernate to Fluent NHibernate

开发者 https://www.devze.com 2023-01-07 05:00 出处:网络
i want to convert this mapping file from NHibernate to Fluent NHibernate <hibernate-mapping xmlns=\"urn:nhibernate-mapping-2.2\">

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"&开发者_如何学Gogt;
        <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.


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

I think the other stuff is OK

0

精彩评论

暂无评论...
验证码 换一张
取 消