【发布时间】:2019-10-10 06:14:23
【问题描述】:
我有一个简单的 C# 控制台应用程序,它的代码是这样的:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Oracle.ManagedDataAccess.Client;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
SHRSContext shrsContext = new SHRSContext();
DbCommand cmd = shrsContext.Database.Connection.CreateCommand();
cmd.CommandText = "PKG_SHRS.GETLOGINATTEMPT";
cmd.CommandType = CommandType.StoredProcedure;
var pinUsername = new OracleParameter("pinUsername", OracleDbType.Varchar2, ParameterDirection.Input);
pinUsername.Value = "admin";
var poutLoginAttemptCount = new OracleParameter("poutLoginAttemptCount", OracleDbType.Int16, ParameterDirection.Output);
cmd.Parameters.Add(pinUsername);
cmd.Parameters.Add(poutLoginAttemptCount);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
Console.WriteLine(poutLoginAttemptCount.Value.ToString());
Console.ReadLine();
}
}
}
它使用实体框架和Oracle 11g 作为后端。它在 PKG_SHRS.GETLOGINATTEMPT 包中调用 Oracle 过程,并且运行良好。
上面的代码只是提供了一个作为数值数据类型的输出参数。如果我需要获取一个表SYS_REFCURSOR 作为输出参数,我需要在给定的代码中进行哪些更改?
【问题讨论】:
标签: c# entity-framework entity-framework-6 entity-framework-4 sys-refcursor