I have two entities in my "domain assembly".
Message
- Id
- Title
- Content
- IsMandatoryReading
MessageUser
- MessageId
- UserId // The user who already read the message
In my "Infrastructure assembly" I have the MessageRepository with the methods Save, Delete, GetAll, GetMany, FindById etc, all refer the entity Message.
Now, I want to show to the user all messages marking those that he not have read it. So, I create the method:
public ICollection<MessageToUserDto> GetMessagesToUser( int userId ) { ... }
The only difference between the entity Message and the DTO MessageToUserDto would be the "IsRead" property which would determines whether the message was already read by the user.
DTO:
MessageToUserDto
- Id
- Title
- Content
- IsMandatory
- IsRead
I read in somewhere that is not a good idea using repository to return DTO.
But what would be better in this case? I need worry about this approach? I'm doing something wrong?
Aucun commentaire:
Enregistrer un commentaire