Skip to content

Instantly share code, notes, and snippets.

@felipebastosweb
Created November 21, 2025 14:40
Show Gist options
  • Select an option

  • Save felipebastosweb/6c6e09caeb1f647144c44e93b7dc4d1b to your computer and use it in GitHub Desktop.

Select an option

Save felipebastosweb/6c6e09caeb1f647144c44e93b7dc4d1b to your computer and use it in GitHub Desktop.
Sempre fazer a API Controller com Join para diminuir a complexidade do app mobile
public class StudentsController : ControllerBase
{
private readonly YourDbContext _context;
public StudentsController(YourDbContext context)
{
_context = context;
}
[HttpGet("explicit-join")]
public async Task<ActionResult<IEnumerable<StudentWithCourseDTO>>> GetStudentsWithExplicitJoin()
{
var studentsWithCourses = await (from s in _context.Students
join c in _context.Courses on s.CourseId equals c.Id
select new StudentWithCourseDTO
{
StudentId = s.Id,
StudentName = s.Name,
CourseName = c.Name
}).ToListAsync();
return studentsWithCourses;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment