public class Department
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
}
public class Employee
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual Department department { get; set; }
}
public class vmEmployeeDepartment
{
public int EmployeeId { get; set; }
public string EmployeeName { get; set; }
public int DepartmentID { get; set; }
public string DepartmentName { get; set; }
}
我想将vmEmployeeDepartment映射到Empolyee
public JsonResult Add(vmMuasher vm)
{
var model = Mapper.Map<vmEmployeeDepartment, Empolyee>(vm);
_EmployeeService.Add(model);
return Json(vm, JsonRequestBehavior.AllowGet);
}
问题是:Emplyee域内的Department对象为null,
如何解决此问题?