Linq 主子表的查询

 

 


var query = (from c in context.Role
//join rf in context.RoleFuns
//on c.Id equals rf.RoleId
select new DTORole()
{
RoleName = c.RoleName,
Id = c.Id,
FunList = (from f in context.RoleFuns
      where f.RoleId == c.Id
     select new DTOFunction() { FunName = f.Function.FunName, Id = f.Id }).ToList<DTOFunction>()
}).ToList();

return query;

posted @ 2018-03-22 21:39  勇敢的心666  阅读(207)  评论(0)    收藏  举报