NHibernate OneToMany中映射属性的问题

时间:2019-03-21 14:55:50

标签: nhibernate nhibernate-mapping

我在 ProductHistory 类的外键上遇到问题,该外键来自 Product 类,我试图使产品列表无济于事< / p>

public class ProductHistoryModel : BaseModel
{
    [NHMA.Id(0, Name = "Id", Column = "Id")]
    [NHMA.Generator(1, Class = "guid.comb")]
    public virtual Guid Id { get; set; }

    [NHMA.Property(0, Length = 200, Type = "AnsiString")]
    public virtual string History { get; set; }

    //[DebuggerBrowsable(DebuggerBrowsableState.Never)]
    //[NHMA.ManyToOne(0, Name = "ProductModel", Cascade = "none")]
    //[NHMA.Column(1, Name = "Id")]
    //private ProductModel Products = null;

    [NHMA.Bag(0, Table = "ProductModel")]
    [NHMA.Key(1, Column = "Product")]
    [NHMA.OneToMany(2, ClassType = typeof(ProductModel))]
    public virtual ProductModel Products { get; set; }

    **[NHMA.Bag(0, Table = "ApiUsers")]
    [NHMA.Key(1, Column = "User")]
    [NHMA.OneToMany(2, ClassType = typeof(ApiUsers))]
    public virtual ApiUsers Users { get; set; }
}

我需要在 productHistory

的获取中获得产品列表
public class ProductModel : BaseModel
{
    [NHMA.Id(0, Name = "Id", Column = "Id")]
    [NHMA.Generator(1, Class = "guid.comb")]
    public virtual Guid Id { get; set; }

    [NHMA.Property(0, Length = 50, Type = "AnsiString")]
    public virtual string Name { get; set; }

    [NHMA.Property]
    public virtual decimal Price { get; set; }

    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    [NHMA.Set(0, Name = "ProductHistoryModel", Generic = true, Lazy = NHMA.CollectionLazy.True, Cascade = "none")]
    [NHMA.Key(1)]
    [NHMA.Column(2, Name = "product")]
    [NHMA.OneToMany(5, NotFound = NHMA.NotFoundMode.Exception, ClassType = typeof(ProductHistoryModel))]
    private IList<ProductHistoryModel> productHistoryModel { get; set; }

}

0 个答案:

没有答案