Open Closed

Can I create ExtraProperties and check their existence before updating or adding new data? #5904


User avatar
0
thuc.nghiem@techplus.vn created
  • ABP Framework version: v7.0.1
  • UI Type: Angular
  • Database System: EF Core ( Oracle.)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:
ObjectExtensionManager.Instance.Modules().ConfigureIdentity(identity =>
        {
            identity.ConfigureUser(user =>
            {
                user.AddOrUpdateProperty<string>(UserConsts.LoanOfficer,
                    options =>
                    {
                        options.Attributes.Add(new RequiredAttribute());
                        options.Attributes.Add(new StringLengthAttribute(UserConsts.MaxLoanOfficerLength));
                        //options.UI.OnEditForm.IsVisible = false;

                    });
                

                user.Validators.Add(context =>
                {
                   //help check exist??
                });

            });
  });

2 Answer(s)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello thuc.nghiem@techplus.vn,

    As you are using RequiredAttribute for LoanOfficer, If you have not passing value for LoanOfficer from UI then it will through error/Exception.

    If you want to implement custom validation you can refer this https://docs.abp.io/en/abp/latest/Object-Extensions#custom-validation

    Regards, Anjali

  • User Avatar
    0
    thuc.nghiem@techplus.vn created

    Hello Anjali. My problem is to check if it already exists and prevent it from being saved to the database. Can you provide a solution for me?

Made with ❤️ on ABP v9.1.0-preview. Updated on November 01, 2024, 05:35