Open Closed

Changing from FullAuditedEntityDto to FullAuditedEntityWithUserDto Id is lost #2356


User avatar
0
cellero created
  • ABP Framework version: v5.0.0
  • UI type: Blazor Server
  • DB provider: EF Core

When updating an ...Application.Contracts Dto from FullAuditedEntityDto to FullAuditedEntityWithUserDto the Id of the entity is no longer available.

I have reviewed this help topic. https://docs.abp.io/en/abp/latest/Data-Transfer-Objects

Can you please advise how to use the ...WithUserDto I need to display the Created and Modified users names in the UI


10 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please share these class code.

  • User Avatar
    0
    cellero created

    Sure.

    I created a new entity using ABP Suite. The entity is simple with just two properties and is a FullAuditedAggregateRoot.

    Then I manually changed the ABP Suite generated code in ...Application.Contracts BookDto.cs Line 6 in place of line 7. That is the only changed made.

    The error occurs when changing the Entity Dto to FullAuditedEntityWithUserDto The BookDto no longer has an Id property

    Toggling back line 7 to the original ABP Suite code, the error goes away.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you change the base class from FullAuditedEntityWithUserDto<Guid> to FullAuditedEntityWithUserDto<Guid, TUserDto>?

  • User Avatar
    0
    cellero created

    TUserDto is not known.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi cellero

    You need to create your TUserDto class. Then configure the map.

  • User Avatar
    0
    cellero created

    I'm not following why this is required.
    Is there a problem with the ...WithUserDto or is this additional coding expected behavior?

    I feel I would be better off creating a ..WithNavigationPropertiesDto to get the details of the Create/Modify/Delete user details. Do you have any sample code for using the ..WithUserDto?

    My use case is to display the Create/Modify audit details in the UI - I was hoping the ..WithUserDto would provide this directly.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Do you have any sample code for using the ..WithUserDto?

    You can refer to the blogging module.

    https://github.com/abpframework/abp/blob/cb46781ab69c76cc39bc076eb56a2a2a2e49580c/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Comments/CommentAppService.cs#L35

  • User Avatar
    0
    cellero created

    Thanks. I am able to set the LastModifier ok, but the Creator has a

     protected set;
    

    How can I set the Creator?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    You can set it in the constructor. and this is Entity not DTO.

  • User Avatar
    0
    cellero created

    Noted, thanks.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11