如何为 Oracle 存储过程生成访问类
我正在使用 c#,目前的想法是通过 sql 查询获取有关存储过程的信息
select OWNER, OBJECT_NAME, ARGUMENT_NAME, DATA_TYPE, IN_OUT from SYS.ALL_ARGUMENTS order by OWNER, OBJECT_NAME, SEQUENCE
,以便可以从输出生成这样的行
oracleCommand.Parameters.Add(parameter.ParameterName, parameter.OracleDbType, parameter.Value, ParameterDirection.Input);
并使用 T4 生成类 我的问题是可以通过 ODP.Net 更清晰地获取存储过程属性还是有一种完全不同的更好方法
I am using c# and currently the idea is getting the Info about stored procedured via sql query
select OWNER, OBJECT_NAME, ARGUMENT_NAME, DATA_TYPE, IN_OUT from SYS.ALL_ARGUMENTS order by OWNER, OBJECT_NAME, SEQUENCE
so one can generate lines like this from the output
oracleCommand.Parameters.Add(parameter.ParameterName, parameter.OracleDbType, parameter.Value, ParameterDirection.Input);
and generate the class with T4
My question is can one get the Stored Procedures Properties more cleanly via ODP.Net or is there a completely different better approach
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我到处搜索一组 T4 模板来为我生成 Oracle 存储过程和数据访问层,但什么也没找到。因此,我在网上找到了一些例子并编写了自己的例子。下面的链接提供了 T4 模板文件,用于为给定 Oracle 模式中的每个表创建基本的 CRUD 存储过程,并在 C# 中创建相应的数据访问层。这些过程和 DAL 被设置为在 Oracle 实体框架内使用。
您需要安装 T4 Editor、T4 Toolkit 和 ODP.Net 才能使用这些脚本。然后,您需要填写架构和连接字符串信息,在 Visual Studio 中加载 T4 模板并运行以“*Script.tt”结尾的 .tt 文件。您可能需要根据需要调整/修改脚本,但也许这些脚本将为您提供一个起点...
https://docs.google.com/open?id=0B_OWWs9xWuRQeHVOOUlscWdSZlN0OU9SMS1fWFMxZw
I searched high and low for a set of T4 templates to generate Oracle stored procedures and data access layers for me and couldn't find anything. So, I found some examples online and wrote my own. The link below has the T4 templates files to create basic CRUD stored procedures for every table in a given Oracle Schema and to create their corresponding Data Access Layers in C#. These procedures and DAL's are setup for use within Oracle's Entity Framework.
You will need T4 Editor, T4 Toolkit, and ODP.Net installed to use these scripts. Then, you need to fill in your schema and connection string info, load the T4 templates in Visual Studio and run the .tt files ending with "*Script.tt". You may need to tweak/modify the scripts for your needs, but maybe these scripts will give you a starting point...
https://docs.google.com/open?id=0B_OWWs9xWuRQeHVOOUlscWdSZlN0OU9SMS1fWFMxZw
www.metadrone.com 可以连接到 Oracle 并根据存储过程和函数及其参数生成代码。
www.metadrone.com can connect to Oracle and generate code based on stored procedures and functions and their parameters.