Skip to content
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

Merged
merged 17 commits into from
May 6, 2022

Conversation

suegarner
Copy link
Contributor

return usersForOrganisation;
}


Copy link
Contributor

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:

dotnet/efcore#20040

Anyway I just wanted to share it with you for awareness. I'll approve it now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

imranazad
imranazad previously approved these changes Mar 31, 2022
Copy link
Contributor

@imranazad imranazad left a 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.

imranazad
imranazad previously approved these changes Apr 14, 2022
@FunmiOsho FunmiOsho merged commit a1be8fb into master May 6, 2022
@mgallagher1980 mgallagher1980 deleted the IDAM-465-UsersAndJobsForOrg branch January 16, 2023 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants