使用automapper获取专利对象属性值

时间:2016-03-01 09:04:55

标签: c# entity-framework automapper

我有3个类从实体框架获取数据:

public class State{ 
   .......
   public string Name{get; set;}
   public IList<City> Cities{get;set;}
}

public class City{ 
     .......
   public string Name{get; set;}
   public State State{get; set;}
}

public class Empleoyee{ 
   ......
   public string Name{get; set;}
   public City City{get; set;}
}

我正在创建一个像这样的员工汇总视图:

Employees
-------------------
CityStateName  CityName  Name

摘要类是这样的:

public class EmpleoyeeSummaryView{ 
   public string Name{get; set;}
   public string CityName{get; set;}
   public string CityStateName{get; set;} ?????
}

我将Mapper.CreateMap<Employee, EmpleoyeeSummaryView>CityStateName映射到empty/null

Employees
-------------------
CityStateName  CityName  Name
               City1     Emp1
               City2     Emp2
               City1     Emp3

0 个答案:

没有答案