最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
用 System.Reflection.Emit 来自动生成调用储存过程的实现
时间:2022-06-30 11:26:06 编辑:袖梨 来源:一聚教程网
/****************************************************************
*
* 用 System.Reflection.Emit 来自动生成调用储存过程的实现!
*
* By http://*lo*stinet*.com
*
* Copyrights : Not-Reversed
*
****************************************************************/
//使用的例子
namespace Lostinet.Sample
{
using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
//定义一个接口,用于定义存储过程
interface INorthwindStoredProcedures
{
//定义存储过程对应的方法
DataSet CustOrderHist(string CustomerID);
//如果储存过程名字和方法名字不同,应该用SqlAccessAttribute来进行说明
[SqlAccess("Employee Sales By Country")]
DataTable EmployeeSalesByCountry(DateTime Beginning_Date,DateTime Ending_Date);
//...more...
//MORE Ideas..
//直接执行SQL语句?
//[SqlAccess(SqlAccessType.SqlQuery,"SELECT * FROM Employees WHERE EmployeeID=@EmpId")]
//DataTable SelectEmployee(int EmpId);
}
class ConsoleApplication
{
[STAThread]
static void Main(string[] args)
{
using(SqlConnection conn=new SqlConnection("server=(local);trusted_connection=true;database=northwind"))
{
//一句话就把实现创建了!
//需要传如 SqlConnection 和 SqlTransaction
//SqlTransaction可以为null
//这个好就好在,只要能得到SqlConnection/SqlTransaction就能用这个方法了,所以兼容 Lostinet.Data.SqlScope
INorthwindStoredProcedures nsp=(INorthwindStoredProcedures)
StoredProcedure.CreateStoredProcedureInterface(typeof(INorthwindStoredProcedures),conn,null);
*
* 用 System.Reflection.Emit 来自动生成调用储存过程的实现!
*
* By http://*lo*stinet*.com
*
* Copyrights : Not-Reversed
*
****************************************************************/
//使用的例子
namespace Lostinet.Sample
{
using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
//定义一个接口,用于定义存储过程
interface INorthwindStoredProcedures
{
//定义存储过程对应的方法
DataSet CustOrderHist(string CustomerID);
//如果储存过程名字和方法名字不同,应该用SqlAccessAttribute来进行说明
[SqlAccess("Employee Sales By Country")]
DataTable EmployeeSalesByCountry(DateTime Beginning_Date,DateTime Ending_Date);
//...more...
//MORE Ideas..
//直接执行SQL语句?
//[SqlAccess(SqlAccessType.SqlQuery,"SELECT * FROM Employees WHERE EmployeeID=@EmpId")]
//DataTable SelectEmployee(int EmpId);
}
class ConsoleApplication
{
[STAThread]
static void Main(string[] args)
{
using(SqlConnection conn=new SqlConnection("server=(local);trusted_connection=true;database=northwind"))
{
//一句话就把实现创建了!
//需要传如 SqlConnection 和 SqlTransaction
//SqlTransaction可以为null
//这个好就好在,只要能得到SqlConnection/SqlTransaction就能用这个方法了,所以兼容 Lostinet.Data.SqlScope
INorthwindStoredProcedures nsp=(INorthwindStoredProcedures)
StoredProcedure.CreateStoredProcedureInterface(typeof(INorthwindStoredProcedures),conn,null);
相关文章
- 俄罗斯搜索引擎官方主站直达-俄罗斯搜索引擎移动端免登入口 03-15
- 茄子漫画极速下载-茄子漫画v5.2.44免费畅读 03-15
- msn中文网首页快速入口-msn官网首页一键直达 03-15
- WhatsApp网页版登录-WhatsApp网页版在线体验 03-15
- ao3网页版快捷登录-AO3网页版一键登录入口 03-15
- 漫蛙manwa防走失官网asia-漫蛙manwa2防走失入口 03-15