Open Closed

IBasicRepository Get and Find Methods doesn't load related entities #1199


User avatar
0
raif created

Check the docs before asking a question: https://docs.abp.io/en/abp/4.2/Entity-Framework-Core#repository-get-find-methods

  • ABP Framework version: v4.2.2
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes

IBasicRepository **Get ** and Find doesn't load related entities when even we set include details to the true

Aggregate Root

Entity

Repo Interface

Repo Implementation

EF Relations

Find Method Result

WithDetailsAsync


7 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    hi

    Did you override the WithDetailsAsync and WithDetails methods?

    https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs#L86

    https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityEfCoreQueryableExtensions.cs#L8

    https://docs.abp.io/en/abp/latest/Best-Practices/Entity-Framework-Core-Integration#repository-implementation https://docs.abp.io/en/abp/4.2/Entity-Framework-Core#loading-related-entities

  • User Avatar
    0
    raif created

    Hello, Thx for the reply. I'm sorry i didn't get it https://docs.abp.io/en/abp/4.2/Entity-Framework-Core#loading-related-entities

    Why should i override WithDetailsAsync and WithDetails methods ?

    I have problem with Find and Get Method not with WithDetailsAsync and

    Wasn't your answer already implemented on base EfCoreRepository class? But somehow i need to pass relation info

  • User Avatar
    0
    raif created

    Doh do i need to set this to able use Find and Get method ?

    "If you don't pass any expression to the WithDetailsAsync method, then it includes all the details using the DefaultWithDetailsFunc option you provide."

    https://docs.abp.io/en/abp/4.2/Entity-Framework-Core#defaultwithdetailsfunc

  • User Avatar
    0
    maliming created
    Support Team

    hi raif

    EfCoreRepository does not know the include() info by default.

    You need to specify it manually.

    Please refer to the implementation of the Identity module: https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs#L86 https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityEfCoreQueryableExtensions.cs#L8

  • User Avatar
    0
    serdar.genc@talentra.net created

    Hi @raif, can you solved this problem ? i have a problem like this.

  • User Avatar
    0
    raif created

    Hi @raif, can you solved this problem ? i have a problem like this.

    Yes, with help of best practice documentation i'm fine. See : https://docs.abp.io/en/abp/latest/Best-Practices/Entity-Framework-Core-Integration#repository-implementation

  • User Avatar
    0
    serdar.genc@talentra.net created

    Hi @raif, can you solved this problem ? i have a problem like this.

    Yes, with help of best practice documentation i'm fine. See : https://docs.abp.io/en/abp/latest/Best-Practices/Entity-Framework-Core-Integration#repository-implementation

    thank you so much. i will try.

Made with ❤️ on ABP v9.1.0-rc.1. Updated on January 17, 2025, 14:13