自动创建一个围绕存储过程C#包装类 [英] Automatically create C# wrapper classes around stored procedures

查看:166
本文介绍了自动创建一个围绕存储过程C#包装类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承真的可以使用一些清理一个相当大的应用程序。因此,在整个应用散落数据访问代码。在代码的屁股,一些业务逻辑类,一些内嵌在传统的ASP页面。

I've inherited a rather large application that really could use some cleanup. There is data access code littered throughout the application. In code behinds, some in business logic classes, some inline in in classic asp pages.

我想要做的就是重构这个代码,删除所有数据访问代码为几个DAL类。

What I'd like to do is refactor this code, removing all the data access code into a few DAL classes.

所有的数据访问是通过存储过程(的Microsoft SQL 2000)完成的。有他们的300-400。

All the data access is done through stored procedures (Microsoft SQL 2000). There are 300-400 of them.

好像应该有分析存储过程的自动化的方式,并自动生成为每个C#方法,绘制方法参数的存储过程的参数,与返回的一个DataTable的方法。

It seems like there should be an automated way to analyse the store procedures, and automatically generate c# methods for each of them, mapping the Method parameters to the stored procedure parameters, with a method returning a datatable.

我没有与ORM产品的经验,我不知道如果我要找的是一个完全成熟的ORM,或只是一个第三方实用工具,将帮助周围产生SP调用简单封装。

I don't have any experience with ORM products, and I'm not sure if what I'm looking for is a full blown ORM, or just a 3rd party utility that will help generate simple wrappers around the sp calls.

推荐答案

如果你有机会到.NET Framework 3.5和LINQ to SQL ,你可以做到这一点很容易,看看这个视频:

If you have access to .NET Framework 3.5 and Linq to SQL, you can do it very easily, check this video:

的LINQ to SQL:使用存储过程

使用现有的存储过程和
功能很容易与LINQ。我们只是
拖拽存储过程到
O / R映射表面和
生成的数据上下文对象调用它们。

Using existing stored procedures and functions is easy with LINQ. We simply drag the stored procedures onto the O/R mapping surface and call them from the generated Data Context object.

这篇关于自动创建一个围绕存储过程C#包装类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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