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

Add DddDbContext #103

Merged
merged 2 commits into from
Sep 23, 2024
Merged

Add DddDbContext #103

merged 2 commits into from
Sep 23, 2024

Conversation

rungwiroon
Copy link
Collaborator

@rungwiroon rungwiroon commented Jul 1, 2024

---------- Review by CodeLleviewer ----------
Summary:
The pull request introduces a new DddDbContext and related entities that follow Domain-Driven Design (DDD) best practices, such as using an Aggregate Root pattern and implementing a protected setter for the entity's Id property. The necessary changes are made to the existing QueryableExtensions class to support this new context.

Additions:

  • New DddDbContext added in src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework/DbContexts/DddDbContext.cs for Domain-Driven Design related entities, including DddA, DddB and DddC classes, with the proper AggregateRoot pattern implementation and protected setter for the entity's Id property.
  • Extension methods added to src/Codehard.Functional/Codehard.Functional.EntityFramework/Extensions/QueryableExtensions.cs class to support IQueryable operations on DddDbContext.
  • Test cases added in src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework.Tests/DddEntityTests.cs, src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework.Tests/DomainEntityTests.cs for DddDbContext, and related entities to ensure proper functionality.

Updates:

  • The base Entity class in src/Codehard.Common/Codehard.Common.DomainModel/Entity.cs is updated with a protected setter for the Id property instead of public init accessor.

Deletes:

  • Test classes DddA, DddB, and DddC in src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework.Tests/Entities/DomainDrivenDesign/ have been removed since they are replaced by their DDD-compliant versions with an AggregateRoot pattern implementation.

Review order:

  1. Begin with the high-level changes in src/Codehard.Common/Codehard.Common.DomainModel/Entity.cs. Review how Entity class has been updated to include a protected setter for the Id property.
  2. Move on to src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework/DbContexts/DddDbContext.cs and check the new DddDbContext implementation, including relationships between DddA, DddB, and DddC entities.
  3. Continue with the extension methods in src/Codehard.Functional/Codehard.Functional.EntityFramework/Extensions/QueryableExtensions.cs, which support IQueryable operations on the new DddDbContext.
  4. Explore test cases for the new context and entities, starting from src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework.Tests/DddEntityTests.cs and then checking src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework.Tests/DomainEntityTests.cs.

Suggestions:

  • Consider adding a DbContextFactory for easily creating instances of DddDbContext in the tests.
  • Think about implementing an OnModelCreating method to separate entity configuration from extension methods in src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework/Extensions/ModelBuilderExtensions.cs.
  • Explore moving common functionality between different contexts into a shared base class or a set of extension methods for better code reusability.

---------- Review by CodeLleviewer ----------

Summary

The pull request introduces a new DddDbContext and related entities that follow Domain-Driven Design (DDD) best practices, such as using an Aggregate Root pattern and implementing a protected setter for the entity's Id property. The necessary changes are made to the existing QueryableExtensions class to support this new context.
Additions

  • A new DddDbContext has been added in src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework/DbContexts/DddDbContext.cs for Domain-Driven Design related entities, including DddA, DddB and DddC classes.
  • Extension methods have been added to src/Codehard.Functional/Codehard.Functional.EntityFramework/Extensions/QueryableExtensions.cs class to support IQueryable operations on DddDbContext.
  • Test cases for the new context and entities have been added in src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework.Tests/DddEntityTests.cs and src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework.Tests/DomainEntityTests.cs.
    Updates

  • The base Entity class in src/Codehard.Common/Codehard.Common.DomainModel/Entity.cs is updated with a protected setter for the Id property instead of public init accessor.
    Deletes

  • Test classes DddA, DddB, and DddC have been removed from src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework.Tests/Entities/DomainDrivenDesign/ since they are replaced by their DDD-compliant versions with an AggregateRoot pattern implementation.
    Review order

  1. Begin with the high-level changes in src/Codehard.Common/Codehard.Common.DomainModel/Entity.cs. Review how Entity class has been updated to include a protected setter for the Id property.
  2. Move on to src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework/DbContexts/DddDbContext.cs and review the new DDD-compliant entities.
  3. Explore test cases for the new context and entities, starting from src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework.Tests/DddEntityTests.cs and then checking src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework.Tests/DomainEntityTests.cs.
    Security review

No sensitive data has been added or exposed in the new codebase.
Suggestions

  • Consider adding a DbContextFactory for easily creating instances of DddDbContext in the tests.
  • Think about implementing an OnModelCreating method to separate entity configuration from extension methods in src/Codehard.Infrastructure/Codehard.Infrastructure.EntityFramework/Extensions/ModelBuilderExtensions.cs.
  • Explore moving common functionality between different contexts into a shared base class or a set of extension methods for better code reusability.

@rungwiroon rungwiroon requested a review from Desz01ate July 1, 2024 10:10
@rungwiroon rungwiroon force-pushed the add-ddd-db-context branch from dcbed5e to b500db4 Compare July 3, 2024 10:00
@rungwiroon rungwiroon force-pushed the add-ddd-db-context branch from b500db4 to cdd6a03 Compare July 4, 2024 06:24
@rungwiroon rungwiroon merged commit b23cbaa into main Sep 23, 2024
5 checks passed
@rungwiroon rungwiroon deleted the add-ddd-db-context branch September 23, 2024 03:21
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