开发者

FluentNHibernate: can't change key column name for a one-to-many relationship

开发者 https://www.devze.com 2022-12-10 23:05 出处:网络
I have an entity: public class Message:Entity { public virtual IList`<`Message> ReplayMessages { set; get; }

I have an entity:

public class Message:Entity
    { 
       public virtual IList`<`Message> ReplayMessages { set; get; }
       public virtual Message ParentMessage { set; get; }
    }

I try to override the mapping:
 mapping.HasMany(x => x.ReplayMessages)
      开发者_JAVA百科          .AsSet()
                .KeyColumnNames.Add("ParentId");

but in the hbm.xml file I get:

<set name="ReplayMessages">
      <key column="MessageFk" />
      <one-to-many class="Edi.Core.Model.Message, Edi.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    </set>

Why the column key name didn't change?


When I use HasMany it looks like this:

HasMany(x => x.OrderItems)
    .KeyColumn("OrderId")
    .AsSet()
    .Cascade.All();

I don't know what KeyColumnNames is used for...

0

精彩评论

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