Is It possible to get the reference to the PositionViewModel
in the following expression tree:
public static Expression<Func<Model, ViewModel>> ToViewModel
{
get
{
return x => new PositionViewModel
{
Id = x.Id,
Name = x.Name,
Employees = x.Employees.Select(e => new Employee
{
Id = e.Id,
Name = e.Name,
Position = ??? // reference to PositionViewModel
}).ToList()
};
}
}
I think it is, because EF does that. Any suggestions?
Edit: Forgot to mention that "Postition" is of type ViewModel.