fluent nhibernate component one-to-many

前端 未结 3 977
执笔经年
执笔经年 2020-12-22 12:28

I have couple of classes and want to map them correctly to database:

public class A
{
    public virtual Guid Id { get; private set; }
    public virtual Com         


        
3条回答
  •  余生分开走
    2020-12-22 13:25

    If you have a one-to-many association direct to a collection of components (ie. without the ComponentClass wrapper as per the question) then you can map it directly:

    HasMany(x => x.Elements)
        .AsSet()
        .Table("ElementTable")
        .KeyColumn("KeyColumn")
        .Cascade.All()
        .Component(x =>
        {
            x.Map(c => c.Id);
            x.Map(c => c.Time);
        })
        .LazyLoad();
    

提交回复
热议问题