public IEnumerable<MemberIndexVodel> FindMemberByNames(IEnumerable<string> names)
{
//这里能不能有另外的一种调用方法?
return ConvertEntityToVodel(this.db.Members.Where(m => names.Contains(m.Name)));
}
private IEnumerable<MemberIndexVodel> ConvertEntityToVodel(IEnumerable<Member> entities)
{
return entities.Select(m => new MemberIndexVodel
{
Id = m.Id,
Name = m.Name,
Captain = m.Captain,
Cellphone = m.Cellphone,
Type = (Enums.MemberType)m.Type,
Remark = m.Remark,
Creatime = m.Creatime,
});
}
相信我,你需要了解一下AutoMapper
from m in this.db.Members
join name in names
on m.Name equals name
select new MemberIndexVodel....;