Open Closed

Find user by extend property #6721


User avatar
0
lan.dang created
  • ABP Framework version: v8.0
  • UI Type: Blazor Server
  • Database System: EF Core
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I have added some property to User table, how can I query user (or Find user) base on that property. I try to find but there is not good answer

Thank you


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

    hi

    https://support.abp.io/QA/Questions/6363/Object-Extension#answer-3a0f8e32-2ac0-ec3a-48f1-7a84e77294c4

    https://learn.microsoft.com/en-us/ef/core/modeling/shadow-properties#accessing-shadow-properties

  • User Avatar
    0
    lan.dang created

    Can you give me example?

    query.WhereIf(input.FullName.IsNotNullOrWhiteSpace(), e => EF.Property<string>(e, "FullName") == input.FullName); What is EF in this line?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    EF.Property is a static method of EF Core.

    https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.ef.property?view=efcore-8.0 https://learn.microsoft.com/en-us/ef/core/modeling/shadow-properties#accessing-shadow-properties

  • User Avatar
    0
    lan.dang created

    But I want to call it in AppService, is it possible? With Tenant I can add my method by create interface public interface ICustomTenantRepository : IRepository<Tenant, Guid> { Task<Tenant> FindBySubscriptionIdAsync(string subscriptionId); } How can I do the same with IdentityUser?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You shouldn't use EF Core in AppService layer.

    You can add an interface in the domain and implement it in the EF Core layer. then use the interface in AppService layer.

  • User Avatar
    0
    lan.dang created

    Thank you I get it works

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09