'How to select only specific properties of navigation property
I've got a simplify entity structure like the following:
class MarkingTask{
List<Task_Student> task_Students
}
class Task_Student{
List<Task_Student_Marker> task_Student_Markers
}
class Task_Student_Marker{
User marker
}
class User{
string name;
int age;
int password;
}
I am doing an eager loading like the following:
var taskList = context.markingTasks
.Include(mt => mt.task_Students)
.ThenInclude(ts => ts.task_Student_Markers)
.ThenInclude(tsm => tsm.marker) //Here, only want to select marker.name
.ToList();
The question is where can I do a select clause on the navigation property to select a few columns of interest? For instance, for now, all of the properties of User are being selected, but I just want the User.name.
I looked up the MSDN, it seems the select clause is not supported inside include clause.
or I have to break it down into several statements.
Thanks for the tip
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
