'.NET6 calling oracle stored procedures with params and refcursor

First time I am using .net6 with entity framework trying to call stored procedure.

CREATE OR REPLACE 
PROCEDURE get_registration
    ( IDIn IN Number DEFAULT null,
            returnRecords Out SYS_REFCURSOR)
    IS
    
BEGIN
    open returnRecords for
    Select *
    from registration
    where ((IDIn is null) or (IDIn = ID))
    order by ID desc;
END; -- Procedure

I think what I have is close but not sure how to bind the result set.

using Oracle.ManagedDataAccess.Client;
using Oracle.EntityFrameworkCore; 
using Microsoft.EntityFrameworkCore;

public int GetorCreateRegistration(Registration id)
{
    if (id != null)
    {
        // create parameters to pass to the exec Stored Procedure statement
        // and bind the parameters with the values passed
         OracleParameter p = new OracleParameter("IDIn", id.ID);
OracleParameter pout = new OracleParameter("results", OracleDbType.RefCursor, ParameterDirection.Output);

        // run the statement to exec Stored Procedure inside the database
        // and capture the return values
   var registrations = _db.REGISTRATION.FromSqlRaw("BEGIN get_registration(:p,:results); END;", new object[] { parameters }).ToList();


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source