Open Closed

How to use extra properites in IQueryable #3688


User avatar
0
mel@quadsoftpa.com created
  • **ABP Framework version:**6rc3
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): MVC

please reference this question and answer https://support.abp.io/QA/Questions/3634/How-to-use-extra-properites-in-IQueryable

I'm trying to do the same thing, but in a module on a second dbContext. in the primary app module I have this and then I can access the extra property,

    ObjectExtensionManager.Instance.Modules()
                          .ConfigureIdentity(identity =>
                           {
                               identity.ConfigureRole(role =>
                               {
                                   role.AddOrUpdateProperty<string>("Code", property =>
                                   {
                                       property.Attributes.Add(new RequiredAttribute());

                                       property.Attributes.Add(new StringLengthAttribute(10)
                                       {
                                           MinimumLength = 1
                                       });
                                   });
                               });
                           });
                           

however in the module I get this error

System.InvalidOperationException: Translation of 'EF.Property<string>(EntityShaperExpression: Volo.Abp.Identity.IdentityRole ValueBufferExpression: ProjectionBindingExpression: EmptyProjectionMember IsNullable: False , "Code")' failed. Either the query source is not an entity type, or the specified property does not exist on the entity type.

please advise. Thank


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

    Hi,

    I think this is same with https://github.com/abpframework/abp/issues/8019#issuecomment-796776155

    Can you check?

  • User Avatar
    0
    mel@quadsoftpa.com created

    now, this is not the same error. my is

    Volo.Abp.Identity.IdentityRole ValueBufferExpression: ProjectionBindingExpression: EmptyProjectionMember IsNullable: False , "Code")' failed. Either the query source is not an entity type, or the specified property does not exist on the entity type.

  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    Yes, this is not the same error, but there are errors of similar logic. In the startup app module, StartupModuleDbContext is configured according to the new property. Still, since this configuration is not done in the dependent module, the dependent module ModuleDbContext does not know about the newly added property. In order for it to work as you said, this configuration must be done in the module.


    I may not have fully understood the problem. So if you think my observations are wrong, please provide more details.

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