Base solution for your next web application
Open Closed

How to do dynamic entity repository injection #7194


User avatar
0
mujthabagroad created

Hello,

Is there any way to inject dynamic entity in service to write a common method to get data from any table? or any inbuilt method available? Purpose: We need to create common lookup service which can get data from any entity to reduce repeated code for lookup table/dropdown services.

Thanks


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

    The current design has no dynamic entity repository.

    I think you can customize a service and use DbContext directly inside the service. This allows you to query using any entity.

  • User Avatar
    0
    mujthabagroad created

    Okay, How it can be done with DbContext in service, Is there any doc related to?

    Thanks.

  • User Avatar
    0
    maliming created
    Support Team

    Try using IDbContextProvider, If you encounter any problems, please feedback.

    https://github.com/aspnetboilerplate/aspnetboilerplate/blob/e0ded5d8702f389aa1f5947d3446f16aec845287/src/Abp.EntityFrameworkCore/EntityFrameworkCore/IDbContextProvider.cs#L6