- ABP Framework version: v3.0.4
- UI type: Angular
- DB provider: EF Core
- Tiered (MVC) or Identity Server Seperated (Angular): no / yes
- Exception message and stack trace:
- Steps to reproduce the issue:
I am using PostgreSQL functions and stored procedure.
I tried using it this approach https://khalidabuhakmeh.com/add-custom-database-functions-for-entity-framework-core
but I got below error: [ERR] xyzFunctionName cannot be called client side
Tried to look into abp document but no luck.
Please provide sample code if available. Thank you in advance !!!
3 Answer(s)
-
0
There's a sample project show how to run Stored Procedures in ABP Framework.
- https://docs.abp.io/en/abp/latest/Entity-Framework-Core#add-custom-repositories
- https://github.com/abpframework/abp-samples/tree/master/StoredProcedureDemo
-
0
Hi @alper,
Below code is for Executing SP on SQL server:
public async Task UpdateEmail(Guid id, string email, CancellationToken cancellationToken = default) { await DbContext.Database.ExecuteSqlRawAsync( "EXEC UpdateEmailById @email, @id", new List<object> {new SqlParameter("id", id), new SqlParameter("email", email)}, cancellationToken); }
I am using PostgreSQL 13 , Is this the same way to execute it on PostgreSQL and even I am not able to find SqlParameter i.e.
new SqlParameter("id", id)
do I need to install any package for same ? -
0
according to the Microsoft docs it supports SqlParameters
https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.relationaldatabasefacadeextensions.executesqlrawasync?view=efcore-5.0#Microsoft_EntityFrameworkCore_RelationalDatabaseFacadeExtensions_ExecuteSqlRawAsync_Microsoft_EntityFrameworkCore_Infrastructure_DatabaseFacade_System_String_System_Object___