Open Closed

How to use custom functions and stored procedure in microservices application #728


User avatar
0
lalitChougule created
  • 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 !!!

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

3 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    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
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    lalitChougule created

    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 ?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    alper created
    Support Team Director

    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___

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.