[英](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: 尝试执行以下操作:
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)
例如,您可以获得公共同义词和显示的集合(包,视图,表等)
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
可能会起作用
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.