标签:map rom list using nbsp 映射 auto 实体映射 ber
实体映射
var list = new List<tb_article>();
using (dataContext = new EPDbContext())
{
list = dataContext.tb_article.Take(10).ToList();
}
AutoMapper.Mapper.CreateMap<tb_article, tb_articleDto>()
.ForMember(d => d.title, opt =>
{
opt.MapFrom(s => s.author);
}).ForMember(d => d.id, opt =>
{
opt.MapFrom(s => s.status);
}); ;
var small_list=AutoMapper.Mapper.Map<List<tb_article>,List<tb_articleDto>> (list);
EF 查询 前 进行 实体映射:提高 效率:
var list = new List<tb_articleDto>();
using (dataContext = new EPDbContext())
{
string str_list = dataContext.tb_article.Take(10).Project().To<tb_articleDto>().ToString();
}
标签:map rom list using nbsp 映射 auto 实体映射 ber
原文地址:https://www.cnblogs.com/zwei1121/p/9076224.html