AutoMapper and convert a datetime to string

前端 未结 3 1715
一向
一向 2021-02-07 02:12

I can\'t get my head round the following issue. I have a feeling it is a limitation of LINQ and expression trees, but not sure how to accept the lambda body. Can I achieve this

3条回答
  •  -上瘾入骨i
    2021-02-07 03:02

    try this:

    Mapper.CreateMap().ForMember(x => x.DateCreated,
      opt => opt.MapFrom(src => ((DateTime)src.DateCreated).ToShortDateString()));
    

提交回复
热议问题