存储过程通用功能 [英] Stored procedure generic function

查看:144
本文介绍了存储过程通用功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天



任何人都可以告诉我如何创建一个能够在我的应用程序中执行所有存储过程的c功能。我想这样做,当我需要执行存储过程时,我所做的就是调用c sharp函数并传递一些参数。



谢谢

问候

Good Day all

Can anyone please tell me how i can create a c sharp function that will execute all my stored procedures throughout my app. i want to do it in such a way that when i need to execute a stored procedure all i do is invoke the c sharp function and pass it some parameters.

thanks
Regards

推荐答案

编写一个通用的方法并不是一个简单的方法,它将执行我所有的存储过程因为程序将具有必须提供的不同参数,并且通用例程将不知道在这些参数中传递什么信息。



但是,你可以制作一个手动执行每个过程的方法。如果你将它标记为静态,它将通过静态MyClass.MyMethod调用在整个应用程序中可用。
It''s not strictly possible to write a generic method that will "execute all my stored procedures" for the simple reason that the procedures will have different parameters which must be supplied and a generic routine will have no idea what information to pass in these parameters.

However, you can make a method for each procedure manually. If you mark it as static, it would be available throughout your app via a static MyClass.MyMethod call.


如果这里的泛型是OO术语 - 这个问题毫无意义,因为SP不在c#的范围内。

如果泛型意味着能够处理任何SP,那么你可能认为没有挣扎于此,因为它太复杂了。

你可以在这里看到的方法: http://kennyshu.blogspot.hu/2008/10/generic-method-for-getting-data-from-db.html [ ^ ]只处理一种检索结果的方案,但你可以用它来满足你的需求。但请相信我,你不会获得太多收益。
If "generic" here is the OO term - than the question makes no sense, since the SP not in the scope of c#.
If "generic" means "capable of handling any SP", than you might consider not struggling with this, since it would be too complex.
The approach you can see here: http://kennyshu.blogspot.hu/2008/10/generic-method-for-getting-data-from-db.html[^] is handling only one scenario of retrieving results, but you can use it to make suitable for your needs. But believe me, you will not gain much.


这篇关于存储过程通用功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆