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

User as aggregate root #26

Merged
merged 4 commits into from
Jan 14, 2024
Merged

User as aggregate root #26

merged 4 commits into from
Jan 14, 2024

Conversation

QimbE
Copy link
Owner

@QimbE QimbE commented Jan 14, 2024

No description provided.

@QimbE QimbE self-assigned this Jan 14, 2024
Comment on lines 88 to 94
{
User result = new(name, email, password, roleId, false);

result.RefreshToken = RefreshToken.Create("sample", result.Id);

result.RaiseEvent(new UserCreatedDomainEvent(result.Id));

Copy link
Owner Author

Choose a reason for hiding this comment

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

Почему тут нет объявления роли? См сюда. Каждый раз, когда пытаешься привязать роль (пусть даже существующую: и Id, и Имя те же) EF Core смотрит на тебя, как на идиота и кидает Exception: duplicate primary key

Copy link
Collaborator

Choose a reason for hiding this comment

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

Не понял что является причиной ошибки, EF Core? Просто из того обсуждения, что ты скинул я вообще не понял, почему это так. Почему ты вообще пытаешься передать роль в метод Create у RefreshToken-а, когда ни в одном методе Create этого класса не используется роль?

Copy link
Owner Author

Choose a reason for hiding this comment

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

А, я не то выделил. Каюсь. Крч там дело в том, что change tracker'у невозможно сказать никак, что какая либо сущность не должна пробрасываться в базу. Поэтому если при создании пользователя делать ещё и роль, то он всегда кидает эксепшион, типа он считает, что я хочу по второму кругу ту же самую роль добавить. А команда EF уже кучу лет пытаются сделать readonly сущности, чтобы это решить.

@QimbE QimbE assigned likeitbro and unassigned likeitbro Jan 14, 2024
@QimbE QimbE requested a review from likeitbro January 14, 2024 08:36
Copy link
Collaborator

Choose a reason for hiding this comment

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

А для чего это здесь было в первую очередь? Ты тестировал и забыл убрать или это несло какую-то смысловую нагрузку?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Тогда я не знал, что можно мыслить "агрегатами"

Copy link
Collaborator

@likeitbro likeitbro left a comment

Choose a reason for hiding this comment

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

Вроде всё норм =D

@QimbE QimbE merged commit 36b763f into develop Jan 14, 2024
1 check passed
@QimbE QimbE deleted the tsepenshchikov/aggregate-factory branch January 14, 2024 17:28
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.

2 participants