AutoMapper和实体框架dbcontext的映射属性

时间:2017-12-22 01:26:40

标签: automapper

我对AutoMapper有点新,我试图映射一个属性,其中来自ef db context的值。

我将如何做到这一点?

CreateMap<User, UserDto>()
.ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.Username))
.ForMember(dest => dest.NetworkId, opt => opt.MapFrom(src => src.NetworkId))
.ForMember(dest => dest.Network, /*NEED TO TAKE NetworkId and PERFORM A lookup in DbContext AND SET Network property*/);

0 个答案:

没有答案