Open Closed

How sould be the CmsUser relation usage with other related entities ? #1575


User avatar
0
selinkoykiran created

Hello, We want to use your UserSynchronizer solution to synchronize user data between microservices and we saw the example inside CmsKit module. But here we have a question. We want to make a relation between our CreatorId which comes from Audit entity and our custom User table inside microservice. Below code, you uses CmsUser entity inside BlogPost entity directly.

But we want to make an implementation like below :

So we are wondering if is there any spesific reason for not using audited entity property ? Why did you put CmsUser as Author and add AuthorId instead of using CreatorId property from FullAuditedAggregateRoot ? Is our implementation also okay ?

Thank you.

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v4.3.0
  • UI type: MVC
  • DB provider: EF Core
  • **Tiered (MVC) :yes -

6 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    HI,

    It depends on business logic, in your business scenario, if the creator must be the author, that's ok. but I do not recommend using audit fields as business fields

  • User Avatar
    0
    selinkoykiran created

    Hello , Our requirement is just show creatorId and lastmodifierId which comes from FullAuditedAggregateRoot in the UI actually like below screenshot. They are in Guid format so we need to show name of the users. But we didn't want to join with AbpUser table directly because it is against the best practices, so we just saw an example in CmsKit and implemented it. So here the question we are asking is, in this case what should we do , this is not depend on business actually , this is related with how we should show creator user data in the UI which comes from audit entites, without joining with user table ?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can use creatorId and lastmodifierId to query users

    like:

      var model = _modelRepository.GetAsync(id);
      
      var createUser = _userRepository.GetAsync(model.CreatorId);
    
  • User Avatar
    0
    selinkoykiran created

    Hello, In Abp framework , do you need or use anything like you mentioned ? Don't you need to show creatorId or lastModifierId in the UI , angular , razor or in anything else ? Because I think this is a common approach and usage scenerio "showing creator or modifier name" in the UI. Could you give a reference from framework to understand the best practise.

    Thank you.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    We also provide FullAuditedAggregateRootWithUser base class. you can use it. see https://docs.abp.io/en/abp/latest/Entities#auditing-base-classes

  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11