Wednesday, January 2, 2019

Entity Framework 6 subquery example

public async Task<IList<ProgramSurvey>> GetProgramSurveysFor(int workshopId)
{
   var query = from programSurvey in _context.ProgramSurveys
      where (from workshop in _context.Workshops
         where workshop.Id == workshopId
         select workshop.ProgramId).Contains(programSurvey.ProgramId)
      select programSurvey;
   return query.ToList();
}

No comments:

Post a Comment