2016-06-13 75 views
1

我有一个对象,其中包含一个值对象列表,但无法找到解决方法如何流利地映射此对象。我有像这样的映射为ComponentMap没有内嵌映射)值对象:流利地映射组件集合

public class ServiceSpecificationMapping : ComponentMap<ServiceSpecification> 
{ 
    public ServiceSpecificationMapping() 
    { 
     Map(x => x.PurposeOfService).Not.Nullable(); 
     Map(x => x.Description).Nullable(); 
     Map(x => x.Price).Not.Nullable(); 
    } 

的含类有这样的定义:

public class ServiceContract : EntityBase 
{ 
    .... 
    public virtual List<ServiceSpecification> ServiceSpecifications { get; set; } 
    ... 

} 

有困难的代码的正确映射。我在寻找的东西,如:

HasMany<ServiceSpecification>(x => x.ServiceSpecifications) 
      .Table("tblServiceSpecification") 
      .Component(<WHAT IS THE CORRECT LAMBDA HERE??>); 

我需要引用ServiceSpecification实例,但我找不到正确的语法。任何帮助将不胜感激。

回答

0
HasMany<ServiceSpecification>(x => x.ServiceSpecifications) 
      .Table("tblServiceSpecification") 
      .Component(m => { 
       m.Map(x => x.PurposeOfService).Not.Nullable(); 
       m.Map(x => x.Description).Nullable(); 
       m.Map(x => x.Price).Not.Nullable(); 
      });