I am trying to write a query that will be designed in DTO, where two of the properties are int arrays. I am getting an error due to a call to Toray () in the projection.
teams = context .Teams .Include("TeamDepartments") .Include("TeamEmployees") .Select(t => new TeamDto { sourceSystemId = t.TeamId, name = t.Name, manager = t.EmployeeIdTeamManager, teamLead = t.EmployeeIdTeamLead, employees = t.TeamEmployees.Select(te => te.EmployeeId).ToArray(), departments = t.TeamDepartments.Select(td => td.DepartmentId).ToArray() }) .ToList();
For employees and departments, which are two int [] properties, how can I get these values? For now, I just undo the list of commands and then iterate over them to create a DTO.
I saw other similar questions, but the solutions do not seem to work for me. I suspect that I need an extra step because I get around the relationship.
Mattio
source share