Can't map Application User with Domain entities. #655
-
I don't have much experience in clean architecture but I am trying my best. The below code got me thinking In order to show sender's name I need to join ApplicationUser but in "Application" it doesn't have any reference. How can send Message list with sender's name
Also, have another same problem need to join user table for getting assigned agent full name
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The public class User
{
public int Id { get; set; }
public string ApplicationUserId { get; set; } // You could also just make this the primary key.
public string Name { get; set; }
public string Email { get; set; }
} This class represents the user within your Domain. Other Domain entities, can include navigation properties to this entity. For example: public class Message
{
public int Id { get; set; }
public string SenderId { get; set; }
public string Text { get; set; }
public User Sender { get; set; }
} With the above approach the Domain is independent of the Identity framework. But there is some effort required to accomplish this independence. For example, the Domain There are certainly other ways to approach this problem, such as moving The approach that you take will always depend on the technical requirements for the solution you are building. Happy Coding! 😀 |
Beta Was this translation helpful? Give feedback.
The
ApplicationUser
extendsIdentityUser
which is considered Infrastructure (relating to the Identity framework). The missing piece is a Domain entity representing your users, let's keep it simple and create aUser
in the Domain:This class represents the user within your Domain. Other Domain entities, can include navigation properties to this entity. For example: