Shahzad
Shahzad

Reputation: 1

Using Entity Framework 6 code first to call stored procedure in Oracle

I am using Entity Framework 6 to fetch records from an Oracle database using a stored procedure which takes an out parameter of collection type. The stored procedure returns results of a select query in the out parameter of collection type. e.g.

procedure GetEmployees(recordset OUT employeesList)
{
    employeesList = select * from employee
} 

How can I call the stored procedure and get results? Or is there any preferred solution?

Upvotes: 0

Views: 940

Answers (1)

Sercan Timoçin
Sercan Timoçin

Reputation: 668

using(var context = new DatabaseContext())
{
        var param1 = new SqlParameter("@Param1", 1);
        var param2 = new SqlParameter("@Param2", 2);

        var result = context.Database
            .SqlQuery<Employee>("SP_NAME @Param1 @Param2", param1,param2)
            .ToList();
}

If Recordset is parameter list. You should change it separately paramters.I have never seen sending parameter list to sp.

Upvotes: 2

Related Questions