Open Closed

ABP Entity Framework store procedure #4726


User avatar
0
mithun created

Please share sample code for using SQL Server DB stored procedure accepting input params and returning multiple rows with Entity Framework COre.

Ours is a tiered application with Blazor Web Assembly as a UI framework with Entity Framework and SQL Server. • ABP Framework version: v5.3 • UI type: / Blazor Web Assembly • DB provider: EF Core • Tiered (MVC) : Yes • Identity Server Separated : yes


7 Answer(s)
  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer

    You can check https://github.com/abpframework/abp-samples/tree/master/StoredProcedureDemo

  • User Avatar
    0
    mithun created

    I tried same approach as sample project. But HttpApi.Host project swagger is throwing attached runtime error. How to see API host runtime exception message?

    Please let me know if we can get into a meeting to resolve the issue.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    HTTP 500

    Please check your app logs(Logs.txt)

  • User Avatar
    0
    mithun created

    Thanks, I'm getting below runtime exception due to dependency injection failure of new custom repository class of stored procedure - IDepartmentsInfoRepository in Application Service class constructor.

    How to resolve custom repository dependency injection issue in application service class?

    2023-03-30 13:19:18.003 +05:30 [ERR] An exception was thrown while activating Castle.Proxies.DepartmentAppServiceProxy.
    Autofac.Core.DependencyResolutionException: An exception was thrown while activating Castle.Proxies.DepartmentAppServiceProxy.
     ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Castle.Proxies.DepartmentAppServiceProxy' can be invoked with the available services and parameters:
    Cannot resolve parameter 'Departments.IDepartmentsInfoRepository DepartmentInfoRepository' of constructor 'Void .ctor(Castle.DynamicProxy.IInterceptor[], Volo.Abp.Domain.Repositories.IRepository`2[Departments.Department,System.Int32], Departments.IDepartmentsInfoRepository, Volo.Abp.Domain.Repositories.IRepository`2[Departments.DepartmentLOB,System.Int32], Microsoft.Extensions.Logging.ILogger`1[Departments.DepartmentAppService], Volo.Abp.Data.IDataFilter, Volo.Abp.Domain.Repositories.IRepository`1[Departments.FreightClassCode], Volo.Abp.Domain.Repositories.IRepository`2[Departments.SKIGenerationForSupply,System.Int32], Volo.Abp.Domain.Repositories.IRepository`2[Departments.SKIGenerationForPrepack,System.Int32], Volo.Abp.Domain.Repositories.IRepository`2[Departments.DepartmentAssortment,System.Int32], Volo.Abp.Domain.Repositories.IRepository`2[Departments.DepartmentLOB,System.Int32], Volo.Abp.Domain.Repositories.IRepository`2[Departments.SubVendor,System.Int32], Volo.Abp.Domain.Repositories.IRepository`1[Departments.DepartmentVendor], Shared.Lookups.ILookupService, Microsoft.Extensions.Localization.IStringLocalizer`1[Localization.SKIResource])'.
       at Autofac.Core.Activators.Reflection.ReflectionActivator.GetAllBindings(ConstructorBinder[] availableConstructors, IComponentContext context, IEnumerable`1 parameters)
       at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
       at Autofac.Core.Activators.Reflection.ReflectionActivator.<ConfigurePipeline>b__11_0(ResolveRequestContext ctxt, Action`1 next)
       at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Builder.RegistrationBuilder`3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext ctxt, Action`1 next)
       at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       --- End of inner exception stack trace ---
       at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request)
       at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request)
       at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
       at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
       at Microsoft.AspNetCore.Mvc.Controllers.ServiceBasedControllerActivator.Create(ControllerContext actionContext)
       at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.&lt;&gt;c__DisplayClass6_0.&lt;CreateControllerFactory&gt;g__CreateController|0(ControllerContext controllerContext)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeNextExceptionFilterAsync&gt;g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
    2023-03-30 13:19:18.003 +05:30 [ERR] ---------- Exception Data ----------
    ActivatorChain = Castle.Proxies.DepartmentAppServiceProxy
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    What's the class name that implement the IDepartmentsInfoRepository?

    It must be EfCoreDepartmentsInfoRepository.

  • User Avatar
    0
    mithun created

    I tried renaming the class getting same exception

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Please share a simple project. thanks

    liming.ma@volosoft.com

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