In Linq i must create a query with method only, i've got 2 tables :
- Students (LastName, FirstName, Result)
- Grades (Max, Min, Name)
I must select students (LastName
, FirstName
) and add to it the grade (Result > Min && Result < Max
).
In the end I must have :
IEnumerable<T> T => LastName, FirstName, Grade
I try this :
var SAG = dc.Students
.Where(w => w.Year_Result >= 12)
.Join(dc.Grades, s => true, g => true, (s, g) =>
new { s.LastName,
s.FirstName,
Grade = g.Name
.Where(w => (w.Min < s.Result)
&& (w.Max > s.Result))
.FirstOrDefault() }).ToList();
But with this request I've only 2 results but I must have 40 results.