there are two tables in the database: the User table and the Score table.
User
id name
1 Young 25
2 Hong 24
Score
id userId course score
10 1 100
11 1 90
12 2 95
13 2 85
at present, I use this linq sentence to check:
(from u in User join s in Score
on u.id equals s.userId
select MapToEntity(u,s)).ToList());
private User MapToEntity(User u, Score s){
u.score = s;
return u;
}
the result of the joint survey is as follows:
{
User{
Young,,25
Score{
10,1,100
}
},
User{
Young,,25
Score{
11,190
}
}
User{
Hong,24
Score{
12,295
}
}
User{
Hong,24
Score{
13,285
}
}
}
< H2 > question < / H2 >
how to get such a result through Linq search:
{
User{
Young,,25
Score{
10,1,100
}
Score{
11,190
}
},
User{
Hong,24
Score{
12,295
}
Score{
13,285
}
}
}