問題描述
我正在開發一個調用 oracle 存儲過程的 API - 我無法觸及它 - 并返回兩個 refcursors.問題是,在我的代碼中,只有從 sp 返回的第一個游標 beign 被映射,而另一個游標則是 InvalidOperationException.
I'm working on an API that calls an oracle stored procedure -I can't touch it- and returns two refcursors. The problem is that in my code, only the first cursor beign returned from the sp gets mapped, while the other one trows an InvalidOperationException.
var sql = "BEGIN CCO_PKG_WHITDRAWREQUEST.OBT_OPCION_RET_DES_PRC(:pi_num_seguro_social , :pi_num_resolucion, :po_cur_valida_res, :po_cur_opciones); END;";
var parameters = new OracleParameter[]
{
new OracleParameter("pi_num_seguro_social", request.NSS),
new OracleParameter("pi_num_resolucion", request.NumResolucion),
new OracleParameter("po_cur_valida_res", OracleDbType.RefCursor, ParameterDirection.Output),
new OracleParameter("po_cur_opciones", OracleDbType.RefCursor, ParameterDirection.Output)
};
//This one gets mapped without problems.
var validaResCursor = await _context.CursorValidaRes.FromSqlRaw(sql, parameters).ToListAsync();
//This one throws the exception.
var opcionesCursor = await _context.CursorOpciones.FromSqlRaw(sql, parameters).ToListAsync();
var result = (opcionesCursor, validaResCursor);
被映射的游標類
[Keyless]
public class ValidaResCursor
{
public string EsCVEValido { get; set; }
public string Opcion { get; set; }
public string Descripcion { get; set; }
public double SaldoA { get; set; }
public double SaldoB { get; set; }
public string Vigencia { get; set; }
}
}
沒有的游標類
[Keyless]
public class OpcionesCursor
{
public string cv { get; set; }
public string tipo { get; set; }
public string descripcion { get; set; }
public double monto { get; set; }
public double salario_bc { get; set; }
}
執行
第一個游標被正確映射(它只有 1 行).
第二個光標拋出錯誤.
這是我第一次在 dotnet 環境中使用 oracle,但我正在遵循 oracle 的官方指南,(參見.https://github.com/oracle/dotnet-db-samples/blob/master/samples/dotnet-core/ef-core/stored-procedure/return-ref-cursor.cs),正如您所見,顯然它僅適用于僅返回一個游標的 sp.有任何想法嗎?任何幫助將不勝感激.
This is the first time I'm working with oracle in a dotnet enviroment, but I'm following the oficial guide from oracle, (see. https://github.com/oracle/dotnet-db-samples/blob/master/samples/dotnet-core/ef-core/stored-procedure/return-ref-cursor.cs) and as you can see, aparently it only works with sp's that returns only one cursor. Any ideas? Any help will be appreciated.
推薦答案
目前 EF Core 不支持:https://github.com/dotnet/efcore/issues/8127 查看鏈接以找到此問題的替代方案.
Currently this is not supported by EF Core: https://github.com/dotnet/efcore/issues/8127 take a look at the link to find alternatives to this problem.
這篇關于實體框架核心 5 - 從單個存儲過程返回兩個 oracle 游標的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!