使用Automapper 3.1.1,我无法编译此映射:
Mapper.CreateMap<Domain.DomainObjects.Entities.Patient, PatientDto>()
.ForMember(x => x.Deleted, opt => opt.MapFrom(input => input.Deleted.HasValue ?
new DateTime(input.Deleted.Value.Ticks, DateTimeKind.Utc) : null ));
错误:
Type of conditional expression cannot be determined because there is no implicit conversion between '<null>' and 'DateTime'
实体:
public class Patient : Entity
{
public virtual DateTime? Deleted { get; set; }
}
感觉好像我错过了一些明显的东西,但无法弄清楚到底是什么。
注:Dto包含
DateTime? Deleted
也