Mapping Composite keys in Fluent NHibernate

前端 未结 4 1578
清歌不尽
清歌不尽 2020-12-14 05:39

I am new to fluent NHibernate. Now I face one problem with mapping composite keys. Can anyone point out the URL or sample please?

4条回答
  •  萌比男神i
    2020-12-14 06:33

    if this is your first class

    public class EntityMap : ClassMap
    {
      public EntityMap()
      {
        UseCompositeId()
          .WithKeyProperty(x => x.Something)
          .WithReferenceProperty(x => x.SomethingElse);
      }
    }
    

    here is the second with a reference on Entity

    public class SecondEntityMap : ClassMap
        {
          public SecondEntityMap()
          {
            Id(x => x.Id);
    
            ....
    
            References(x => x.EntityProperty)
              .WithColumns("Something", "SomethingElse")
              .LazyLoad()
              .Cascade.None()
              .NotFound.Ignore()
              .FetchType.Join();
    
          }
        }
    

提交回复
热议问题