What is the best method INNER JOIN for Users?
delgec opened this issue · comments
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
};
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