Open Closed

How do I search extended fields in ABP? #2729


User avatar
0
alper created
Support Team Director

I've added two columns to my IdentityUser table in their own columns. The columns are Title and Nickname, How do I search the IdentityUser table by the extended field named Nickname to return the user using LINQ to the entity?

( u => u.Nickname == 'John' )

1 Answer(s)
  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    If you're trying to do this for the ExtraProperties field in the database, you can't. Because the properties set in the ExtraProperties field are stored as a single JSON object.


    However, you can refer to this document which explains the more natural way to do it.

    If you have already mapped the property to ef core as stated in the document, you can use the query, below. Because the property you add is kept as a separate column in the database table.

    var query = (await GetQueryableAsync()).Where(u => EF.Property<string>(u, "Nickname") == "John");
    

    References:

    1. https://github.com/abpframework/abp/blob/dev/docs/en/Community-Articles/2021-05-24-Removing-EfCore-Migrations/POST.md#querying-based-on-a-custom-property
    2. https://github.com/abpframework/abp/blob/dev/docs/en/Community-Articles/2021-05-24-Removing-EfCore-Migrations/POST.md#mapping-to-the-database-table
Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11