Starts in:
2 DAYS
17 HRS
10 MIN
53 SEC
Starts in:
2 D
17 H
10 M
53 S
Open Closed

Entity with recursion - GetListAsync api is not working and not even displaying on index page - Generated using abp suite #6999


User avatar
0
surajlokhandemmew created

ABP Framework version: v8.0.0

UI Type: MVC + Flutter

Database System: MongoDB

Tiered (for MVC) or Auth Server Separated (for Angular): no

Below is the entity with recursion

public abstract class ChatResourceDtoBase : FullAuditedEntityDto<Guid>, IHasConcurrencyStamp
{
    public string? ChipTitle { get; set; }
    public string? ChipTitleArabic { get; set; }
    public string? Color { get; set; }
    public string? BackColor { get; set; }
    public string? Action { get; set; }
    public string? ExtraField { get; set; }
    public Guid? ChatResourceId { get; set; }

    public string ConcurrencyStamp { get; set; } = null!;

}    

And here is the API

 [Authorize(MyDhobiPermissions.ChatResources.Default)]
 public abstract class ChatResourcesAppServiceBase : ApplicationService
 {
     protected IDistributedCache<ChatResourceExcelDownloadTokenCacheItem, string> _excelDownloadTokenCache;
     protected IChatResourceRepository _chatResourceRepository;
     protected ChatResourceManager _chatResourceManager;

     public ChatResourcesAppServiceBase(IChatResourceRepository chatResourceRepository, ChatResourceManager chatResourceManager, IDistributedCache<ChatResourceExcelDownloadTokenCacheItem, string> excelDownloadTokenCache)
     {
         _excelDownloadTokenCache = excelDownloadTokenCache;
         _chatResourceRepository = chatResourceRepository;
         _chatResourceManager = chatResourceManager;
     }

     public virtual async Task<PagedResultDto<ChatResourceWithNavigationPropertiesDto>> GetListAsync(GetChatResourcesInput input)
     {
         var totalCount = await _chatResourceRepository.GetCountAsync(input.FilterText, input.ChipTitle, input.ChipTitleArabic, input.Color, input.BackColor, input.Action, input.ExtraField, input.ChatResourceId);
         var items = await _chatResourceRepository.GetListWithNavigationPropertiesAsync(input.FilterText, input.ChipTitle, input.ChipTitleArabic, input.Color, input.BackColor, input.Action, input.ExtraField, input.ChatResourceId, input.Sorting, input.MaxResultCount, input.SkipCount);

         return new PagedResultDto<ChatResourceWithNavigationPropertiesDto>
         {
             TotalCount = totalCount,
             Items = ObjectMapper.Map<List<ChatResourceWithNavigationProperties>, List<ChatResourceWithNavigationPropertiesDto>>(items)
         };
     }

     public virtual async Task<ChatResourceWithNavigationPropertiesDto> GetWithNavigationPropertiesAsync(Guid id)
     {
         return ObjectMapper.Map<ChatResourceWithNavigationProperties, ChatResourceWithNavigationPropertiesDto>
             (await _chatResourceRepository.GetWithNavigationPropertiesAsync(id));
     }

Since GetListAsync is returning 0 items but on creation data is getting saved properly in database , please help me resolve this issue ,what could be the cause and how can i resolve it ?


32 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Could you share a simple project or full steps to reproduce the problem? I will check it. thanks

  • User Avatar
    0
    surajlokhandemmew created

    Open abp suite

    Create Entity as mensioned

    then save and generate after that add navigation property as same entity

    now again save and generate, there is no error nothing just GetListAsync not returning values in recursive way its just 0 items

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    This is because of the Action field.

    Action is reserved keywords used by MVC's routing system, you can't use it.

    See: https://github.com/dotnet/aspnetcore/wiki/MVC-Reserved-Keywords

  • User Avatar
    0
    surajlokhandemmew created

    okay great but abp suite can be smart enough to avoid such errors, my previous question was also wasted can you help me with this master child relation? i cant see order details on order page but with query i get data

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I guess the problem has been fixed in the next version.

    Could you update your project and CLI&Suite to 8.1.0 and try again?

  • User Avatar
    0
    surajlokhandemmew created

    okay will try that , also i have query like to update password and phone confirmation property etc. i am using below snippet but its throwing exception

    using private readonly IIdentityUserAppService _identityUserRepository;

        await  _identityUserRepository.UpdatePasswordAsync(userdetails.Id, identityUserUpdatePasswordInput);
    
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    What exception?

  • User Avatar
    0
    surajlokhandemmew created

    This exception was originally thrown at this call stack: Microsoft.AspNetCore.Authorization.AbpAuthorizationServiceExtensions.CheckAsync(Microsoft.AspNetCore.Authorization.IAuthorizationService, Microsoft.AspNetCore.Authorization.AuthorizationPolicy) Volo.Abp.Authorization.MethodInvocationAuthorizationService.CheckAsync(Volo.Abp.Authorization.MethodInvocationAuthorizationContext) Volo.Abp.Authorization.AuthorizationInterceptor.AuthorizeAsync(Volo.Abp.DynamicProxy.IAbpMethodInvocation) Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(Volo.Abp.DynamicProxy.IAbpMethodInvocation) Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter<TInterceptor>.InterceptAsync(Castle.DynamicProxy.IInvocation, Castle.DynamicProxy.IInvocationProceedInfo, System.Func<Castle.DynamicProxy.IInvocation, Castle.DynamicProxy.IInvocationProceedInfo, System.Threading.Tasks.Task>) Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(Castle.DynamicProxy.IInvocation, Castle.DynamicProxy.IInvocationProceedInfo) Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(Volo.Abp.DynamicProxy.IAbpMethodInvocation) Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter<TInterceptor>.InterceptAsync(Castle.DynamicProxy.IInvocation, Castle.DynamicProxy.IInvocationProceedInfo, System.Func<Castle.DynamicProxy.IInvocation, Castle.DynamicProxy.IInvocationProceedInfo, System.Threading.Tasks.Task>) Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(Castle.DynamicProxy.IInvocation, Castle.DynamicProxy.IInvocationProceedInfo) ... [Call Stack Truncated]

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Could you please share the full error log? thanks.

  • User Avatar
    0
    surajlokhandemmew created

    See https://autofac.rtfd.io/help/no-constructors-bindable for more info. at Autofac.Core.Activators.Reflection.ReflectionActivator.<>c__DisplayClass14_0.<UseSingleConstructorActivation>b__0(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Builder.RegistrationBuilder3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext context, Action1 next) at Autofac.Builder.RegistrationBuilder3.<>c__DisplayClass39_0.<OnActivated>b__0(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) --- End of inner exception stack trace --- at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Builder.RegistrationBuilder3.<>c__DisplayClass35_0.<OnPreparing>b__0(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request) at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Volo.Abp.IdentityServer.Tokens.TokenCleanupBackgroundWorker.DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) at Volo.Abp.BackgroundWorkers.AsyncPeriodicBackgroundWorkerBase.DoWorkAsync(CancellationToken cancellationToken) 2024-04-11 05:58:20.147 +04:00 [ERR] ---------- Exception Data ---------- ActivatorChain = Castle.Proxies.TokenCleanupServiceProxy

    2024-04-11 05:58:20.329 +04:00 [WRN] ---------- RemoteServiceErrorInfo ---------- { "code": null, "message": "Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown.", "details": "UserFriendlyException: Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown.\r\nSTACK TRACE: at MyDhobi.Verify.VerifiationProcessService.PostUpdatePassword(UpdatePasswordDto input) in C:\Users\Suraj\OneDrive\Desktop\MyLaundry\Code\abp\Backoffice\ver 1.0\mydhobi\src\MyDhobi.Application\Verify\VerifiationService.cs:line 201\r\n at lambda_method5652(Closure, Object)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.

    2024-04-11 05:58:20.340 +04:00 [WRN] Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown. Volo.Abp.UserFriendlyException: Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown. at MyDhobi.Verify.VerifiationProcessService.PostUpdatePassword(UpdatePasswordDto input) in C:\Users\Suraj\OneDrive\Desktop\MyLaundry\Code\abp\Backoffice\ver 1.0\mydhobi\src\MyDhobi.Application\Verify\VerifiationService.cs:line 201 at lambda_method5652(Closure, Object) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.

    • UserName - UserId : -
    • ClientIpAddress : ::1
    • ExecutionDuration : 51307280
    • Actions:
      • Volo.Abp.Identity.IdentityUserAppService.UpdatePasswordAsync (518 ms.) {"id":"3e6973a6-2e9b-e09f-f300-3a10f77ae71c","input":{}}
      • MyDhobi.Verify.VerifiationProcessService.PostUpdatePassword (51305245 ms.) {"input":{"userId":"987654321","password":"ajay1234","code":"4454"}}
    • Exceptions:
      • Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown. Volo.Abp.Authorization.AbpAuthorizationException: Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown. at Microsoft.AspNetCore.Authorization.AbpAuthorizationServiceExtensions.CheckAsync(IAuthorizationService authorizationService, AuthorizationPolicy policy) at Volo.Abp.Authorization.MethodInvocationAuthorizationService.CheckAsync(MethodInvocationAuthorizationContext context) at Volo.Abp.Authorization.AuthorizationInterceptor.AuthorizeAsync(IAbpMethodInvocation invocation) at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Auditing.AuditingInterceptor.ProceedByLoggingAsync(IAbpMethodInvocation invocation, AbpAuditingOptions options, IAuditingHelper auditingHelper, IAuditLogScope auditLogScope) at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at MyDhobi.Verify.VerifiationProcessService.PostUpdatePassword(UpdatePasswordDto input) in C:\Users\Suraj\OneDrive\Desktop\MyLaundry\Code\abp\Backoffice\ver 1.0\mydhobi\src\MyDhobi.Application\Verify\VerifiationService.cs:line 185
      • Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown. Volo.Abp.UserFriendlyException: Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown. at MyDhobi.Verify.VerifiationProcessService.PostUpdatePassword(UpdatePasswordDto input) in C:\Users\Suraj\OneDrive\Desktop\MyLaundry\Code\abp\Backoffice\ver 1.0\mydhobi\src\MyDhobi.Application\Verify\VerifiationService.cs:line 201 at lambda_method5652(Closure, Object) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.
  • User Avatar
    0
    surajlokhandemmew created

    Hi,

    I guess the problem has been fixed in the next version.

    Could you update your project and CLI&Suite to 8.1.0 and try again?

    Still same unable to see order details. dop i have to regenerate everything after update?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Still same unable to see order details. dop i have to regenerate everything after update?

    Please share the full steps

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    2024-04-11 05:58:20.329 +04:00 [WRN] ---------- RemoteServiceErrorInfo ---------- { "code": null, "message": "Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown.", "details": "UserFriendlyException: Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown.\r\nSTACK TRACE: at MyDhobi.Verify.VerifiationProcessService.PostUpdatePassword(UpdatePasswordDto input) in

    Seems like you don't have the permission, make sure the permission is assigned.

  • User Avatar
    0
    surajlokhandemmew created

    2024-04-11 05:58:20.329 +04:00 [WRN] ---------- RemoteServiceErrorInfo ---------- { "code": null, "message": "Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown.", "details": "UserFriendlyException: Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown.\r\nSTACK TRACE: at MyDhobi.Verify.VerifiationProcessService.PostUpdatePassword(UpdatePasswordDto input) in

    Seems like you don't have the permission, make sure the permission is assigned.

    but its an open api , forgot passowrd, how can i add permission here?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    If it is allowed anonymous access, you can add the [AllowAnonymous] to the method.

  • User Avatar
    0
    surajlokhandemmew created
     var userdetails = await _identityUserRepository.GetAsync(userId);
     if(userdetails != null)
     {
         if(type == 0)
             userdetails.PhoneNumberConfirmed = true;
         else
         userdetails.EmailConfirmed = true;
         var userUpdateDto = ObjectMapper.Map<IdentityUserDto, IdentityUserUpdateDto>(userdetails);
         await _identityUserRepository.UpdateAsync(userId, userUpdateDto);
         return "true";
     }
    

    Shhould i Add this IdentityUserDto, IdentityUserUpdateDto mapping manually or there is alternative? I am getting mapping no0t found error

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    You can add the object mapper config if you need: https://docs.abp.io/en/abp/latest/Object-To-Object-Mapping#define-mappings

  • User Avatar
    0
    surajlokhandemmew created

    I really appreciate you responding to all my queries. I will explain that order thing, meanwhile i just need to know is there any inbuild method available in abp framwork to encrypt and decrypt the payload?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I guess you are looking for this https://docs.abp.io/en/abp/latest/String-Encryption

  • User Avatar
    0
    surajlokhandemmew created

    Not actually this one is simple string encryption , i am looking for complete payload encryption at client app and decryption on server basically more like middleware which can intercept all api requests and decrypt the payload before actually calling the api. the request will be encrypted at client app - mobile or angular whatever.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    No, ABP does not provide such functionality.

    You can search it on Google: https://www.google.com/search?q=aspnet+core+encrypt+response&oq=aspnet+core+encrypt+response

    And I think the main question of the ticket is solved, can we close this? Thanks.

  • User Avatar
    0
    surajlokhandemmew created

    [AllowAnonymous] still not working getting authorization error

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Could you share the full steps to reproduce, thanks.

  • User Avatar
    0
    surajlokhandemmew created

    Below is the method

      [AllowAnonymous]
      public async Task<bool> PostUpdatePassword(UpdatePasswordDto input)
      {
          try
          {
              var userdetails = await _identityRepository.FindByNormalizedUserNameAsync(input.userId);
    
              var query = await _verificationCodeRepository.GetQueryableAsync();
              VerificationCode val = new VerificationCode();
               val = query.Where(x => x.PhoneNumber == userdetails.PhoneNumber && x.Validity > DateTime.Now).OrderByDescending(x => x.Validity).FirstOrDefault();
         
              if (val.Code == input.Code)
              {
                 // var userdetails = await _identityUserRepository.GetAsync(userId);
                  if (userdetails != null)
                  {
                      IdentityUserUpdatePasswordInput identityUserUpdatePasswordInput = new IdentityUserUpdatePasswordInput();
                      identityUserUpdatePasswordInput.NewPassword = input.Password;
    
                    //   var userUpdateDto = ObjectMapper.Map<IdentityUserDto, IdentityUserUpdateDto>(userdetails);
                     await  _identityUserRepository.UpdatePasswordAsync(userdetails.Id, identityUserUpdatePasswordInput);
                     //  await _identityUserRepository.UpdateAsync(userdetails.Id, userUpdateDto);
                      return true;
                  }
                  else
                  {
                      return false;
                  }
    
              }
              else
                  return false;
    
          }
          catch (Exception e)
          {
              throw new UserFriendlyException(e.Message);
          }
      }
    
    
    

    i am getting exception on this line await _identityUserRepository.UpdatePasswordAsync(userdetails.Id, identityUserUpdatePasswordInput); actually its working on localhost but not on server

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    The IdentityUserRepository doesn't have the UpdatePasswordAsync method.

    You must be using the IdentityUserAppService and permission is required.

    I think the reason is obvious, you need to create your own app service instead of using IdentityUserAppService

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