【发布时间】:2018-01-31 21:24:58
【问题描述】:
使用 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
{
// more properties
public virtual DateTime? Deleted { get; set; }
}
感觉好像我遗漏了一些明显的东西,但无法弄清楚到底是什么。
注意:Dto 也包含DateTime? Deleted
【问题讨论】:
标签: c# automapper