开发者

How to mapping that tables using NHibernate (Fluent or XML)

Can you help-me with that database :

How to mapping that tables using NHibernate (Fluent or XML)

I´m using Fluent NHibernate, but XML h开发者_Python百科elps too... My problem is with ProductPrice table...

Thanks

Paul


Nothing special...

<class name="ProductPrice">
  <id name="Id">
    <generator class="..."/>
  </id>
  <property name="Price"/>
  <property name="IsSale"/>
  <property name="PriceSale"/>
  <property name="Sku"/>
  <many-to-one name="ProductSize" column="SizeProductFk"/>
  <many-to-one name="ColorProduct" column="ColorProductFk" />
</class>

Of course you have to map ProductSize and ColorProduct as entities.


NHibernate now supports JPA (called NPersistence or NPA for the .NET platform) including JPA annotations. It is the best way to map entities and have your code portable for other vendors as well. check it out: www.npersistence.com

If you use NPersistence, you simply map:

[Entity]

class ProductPrice

{
    [Id]
    public virtual int Id {get; set;}`

    public virtual int Price {get; set;}
    public virtual int IsSale {get; set;}
    public virtual int Id {get; set;}

    [ManyToOne]
    [Column(Name="SizeProductFk")]
    public virtual ProductSize {get; set;}
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜