1
根據Valueinjecter與源和目標的映射通常使用命名約定完成。但它不適用於我的情況,我如何管理導航屬性的映射。Omu.ValueInjecter與EF中的導航屬性的映射
DTO
public class EmployeeDTO
{
public long EmployeeId { get; set; }
public long? LoginId { get; set; }
public string EmpNumber { get; set; }
public string FirstName { get; set; }
public string CompanyEmail { get; set; }
public string PersonalEmail { get; set; }
public AttendanceTimeSlotDTO AttendanceTimeSlot { get; set; }
}
public class AttendanceTimeSlotDTO
{
public int SlotId { get; set; }
public TimeSpan InTime { get; set; }
public TimeSpan OutTime { get; set; }
}
MYDATA提供
public List<EmployeeDTO> GetActiveEmployees()
{
var employees = UnitOfWork.EmployeeRepository.Get(employee => employee.IsActive, null, "AttendanceTimeSlot").ToList();
//This work fine
var employeesDto = employees.Select(x => new EmployeeDTO().InjectFrom(x)).Cast<EmployeeDTO>().ToList();
employeesDto.InjectFrom(employees);
// Not Working
var result =employees.Select(e => new AttendanceTimeSlot().InjectFrom(e)).Cast<AttendanceTimeSlot>()
.Select(x => new EmployeeDTO().InjectFrom(x)).Cast<EmployeeDTO>().ToList();
}
MYEF
public long EmployeeId { get; set; }
public Nullable<long> LoginId { get; set; }
public string EmpNumber { get; set; }
public string FirstName { get; set; }
public virtual ICollection<Attendance> Attendances { get; set; }
public virtual ICollection<PermanentAddress> PermanentAddresses { get; set; }
public virtual ICollection<TemporaryAddress> TemporaryAddresses { get; set; }
public virtual AttendanceTimeSlot AttendanceTimeSlot { get; set; }
如何將我的地圖導航性能與OMU.ValueInjector