-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IDAM-465 Add users and job ids for an organisation #149
Conversation
return usersForOrganisation; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's possible to make this more concise by doing a projection, so something like this would give you everything rather than doing the separate bits i.e. getting jobs, then users and jobs and then users for organisation:
(from job in Jobs
where job.OrganisationId == organisationId
join user in Users on job.UserId equals user.UserId
join organisation in Organisations on job.OrganisationId equals organisation.OrganisationId
group job by new { job.JobId } into grp
select new UserAndJobForOrganisation
{
OrganisationId = organisationId,
Organisation = new ApiModels.Organisation(grp.Key.organisation),
Users = (List<UserAndJobId>)grp.Select(s => new UserAndJobId()
{
UserId = s.UserId,
User = new ApiModels.User(s.User),
JobId = s.JobId
})
}
).ToList()
However, I've been trying to get it to work and it just won't work. I think it's because of a bug in EF 3.1 which hasn't been resolved:
Anyway I just wanted to share it with you for awareness. I'll approve it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. Just a comment regarding the projections query.
Should return empty object for DELETE only.
https://nicedigital.atlassian.net/browse/IDAM-465