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

What is the best method INNER JOIN for Users? #1071

Open
delgec opened this issue Dec 13, 2023 · 1 comment
Open

What is the best method INNER JOIN for Users? #1071

delgec opened this issue Dec 13, 2023 · 1 comment

Comments

@delgec
Copy link

delgec commented Dec 13, 2023

Hi guys

I have a tiny question for you.

IApplicationDbContext interface doesn't inherite IdentityDbContext.
How to INNER JOIN a related table with the users table?

Example:

var query = from c in _context.Comments
            join u in _context.Users on c.UserId equals u.Id
            where c.ListingId == request.ListingId && c.Status == CommentStatus.Published
            orderby c.Id descending
            select new CommentsVm
            {
                Id = c.Id,
                Body = c.Body,
                CreatedAt = c.CreatedAt,
                Username = u.UserName,
                PhotoURL= u.PhotoURL
            };
@wiecek1873
Copy link

Hello!

I'm not from the Clean Architecture team, but I might be able to provide some insight.

If you want to perform an INNER JOIN with the users table in your context where IApplicationDbContext does not inherit from IdentityDbContext, you can refer directly to the table that contains user information. Typically, this table is named AspNetUsers.

Alternatively, you can utilize the IdentityService.cs that is already implemented in the template.

Best regards,
Michał Więcek

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

No branches or pull requests

2 participants