简体   繁体   English

(使用Visual Studio 2013)如何使用Entity Framework在oracle包内调用存储过程?

[英](using Visual Studio 2013) How to call a Stored Procedure inside an oracle package with Entity Framework?

I have tried to add oracle procedures that placed inside the package using EF5 with ADO.NET Entity Data Model and nothing get imported. 我尝试添加使用带有ADO.NET实体数据模型的EF5放置在包中的oracle过程,而没有导入任何内容。 I cannot see any procedures. 我看不到任何程序。

I am using ODAC 12c Release 3 - > Oracle Data Provide. 我正在使用ODAC 12c第3版-> Oracle Data Provide。

I can import procedures that created outside the package. 我可以导入在包外部创建的过程。

Our development standard is to use oracle packages to define procedures. 我们的开发标准是使用oracle包定义过程。 I am now moving from VS2008 to VS2013 with Entity Framework. 我现在从Entity Framework从VS2008迁移到VS2013。

Please advise and provide possible solutions to overcome this problem. 请提出建议并提供可能的解决方案来解决此问题。 Many Thanks. 非常感谢。

Here's how I did something similar in a recent project. 这就是我在最近的项目中做过类似事情的方式。 Note that I use DevArt instead of ODAC, but perhaps you'll find some inspiration here to solve your issue. 请注意,我使用的是DevArt而不是ODAC,但是也许您会在这里找到一些启发来解决您的问题。

I first created a class that held all parameters required for the function: 我首先创建了一个类,其中包含该功能所需的所有参数:

public class MyFunctionParameter
{
    public DateTime? MyDateTime { get; set; }

    public string Source { get; set; }
}

This class also contained a ToOracleParameters() method. 该类还包含一个ToOracleParameters()方法。 Note that OracleParameter is from DevArt : 请注意, OracleParameter来自DevArt

public List<OracleParameter> ToOracleParameters()
{
    return new List<OracleParameter>
    {
        new OracleParameter("My_Date_Time", OracleDbType.Date, MyDateTime, ParameterDirection.Input),
        new OracleParameter("Source", OracleDbType.VarChar, Source, ParameterDirection.Input),
        new OracleParameter("ID", OracleDbType.Number, ParameterDirection.Output)
    };
}

In my method I then used this class like this: 然后,在我的方法中,我像这样使用此类:

var parameters = parameter.ToOracleParameters();
var inParameterList = string.Join(", ", 
    parameters.Where(x => x.Direction == ParameterDirection.Input)
        .Select(x => ":" + x.ParameterName));
var outParameter = parameters.Single(x => x.Direction == ParameterDirection.Output);
var sql = string.Format("BEGIN :{0} := MY_ORACLE_FUNCTION({1}); end;", 
    outParameter.ParameterName, inParameterList);

DbContext.Database.SqlQuery<object>(sql, parameters.Cast<object>().ToArray()).SingleOrDefault();

try to do the following: 尝试执行以下操作:

  1. In Server Explorer-->Data connections you will see the connection you have made to generate your model. 在服务器资源管理器->数据连接中,您将看到为生成模型而进行的连接。 You can modify the connection from there. 您可以从那里修改连接。 There is a Tab called Filter, from where you can set many objects you can see. 有一个名为“过滤器”的选项卡,您可以在其中设置可以看到的许多对象。 For example, you can get the public synonyms and displayed collections (packages, views, tables, etc) 例如,您可以获得公共同义词和显示的集合(包,视图,表等)

  2. I am not an Oracle expert, but, can you create a public synonym for a procedure wich is inside a package? 我不是Oracle专家,但是,您可以为包内的过程创建公共同义词吗? Probably it would work 可能会起作用

  3. If you cannot find a solution, you can go here: https://community.oracle.com/community/database/developer-tools/windows_and_.net 如果找不到解决方案,则可以转到此处: https : //community.oracle.com/community/database/developer-tools/windows_and_.net

Some of the guys who have developed the Entity Framework for Oracle probably will help you. 一些为Oracle开发了Entity Framework的人可能会为您提供帮助。

Hope it helps. 希望能帮助到你。

Regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Entity Framework在oracle包中调用存储过程? - How to call a Stored Procedure inside an oracle package with Entity Framework? 使用Entity Framework在事务内部调用存储过程 - Call stored procedure inside transaction using Entity Framework 如何使用实体框架调用接受 RefCursor 作为输出参数的 Oracle 存储过程 - How to call Oracle stored procedure which accepts RefCursor as out parameter using Entity Framework 使用Entity Framework调用oracle包/过程 - Calling oracle package/procedure using Entity Framework 如何使用Entity Framework代码优先调用存储过程? - How to call stored procedure using Entity Framework code-first? 如何在实体框架中调用带有联接的存储过程? - How to call Stored Procedure with Joins in Entity framework? 实体框架中的调用存储过程 - Call Stored Procedure In Entity Framework 如何在C#(Visual Studio 2013)中使用Crystal Report 8.5将参数传递给存储过程? - How to pass parameter to a stored procedure in using Crystal Report 8.5 at C# (visual studio 2013)? 使用带有 output 参数的实体框架调用 Oracle 存储过程? - Calling Oracle stored procedure using Entity Framework with output parameter? 在Visual Studio 2013中使用实体框架无法读取sqlite数据库 - cannot read sqlite database , using entity framework in visual studio 2013
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM