从SQL数据库表中的C#类 [英] C# class from a SQL database table

查看:210
本文介绍了从SQL数据库表中的C#类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

遇到这样的:

HTTP ://www.eggheadcafe.com/articles/adonet_source_code_generator.asp

和想知道如果这是正确的解决方案,因为我没有那么大风扇每一个存储过程创建一个类或做我使用企业库ASP.net 2.0的项目。

And wondering if this is the right solution as I am not that big of a fan of creating a class for every stored procedure or do I use Enterprise Library for ASP.net 2.0 project.

推荐答案

您绝对不该 T为为每一个存储过程的类。有一些你可以采取的处理你的数据库交互的方法。你应该在主要的框架存在良好的外观,并决定哪一个最适合你。城堡项目的解决方案是很大的,并且依赖于NHibernate的( NHibernate的)。 LINQ是知春里( LINQ项目)类似的产品。这两种解决方案都充满ORM框架(对象关系映射),并会生成动态SQL坚持在数据库中的对象。每个也有它自己的怪癖,喜欢你构成以特别的方式你的对象。如果你不想管理系统使用SQL,我肯定会推荐这些方法之一。

You definitely shouldn't be creating a class for every stored procedure. There are a number of approaches you can take to handling your database interactions. You should have a good look at the major frameworks out there and decide which one best suits you. The Castle Project solution is great, and relies on nHibernate (nHibernate). LINQ is a similar offering by Mircrosoft (LINQ Project). Both of these solutions are full ORM frameworks (Object Relational Mapping) and will generate dynamic SQL to persist your objects in the database. Each also has it's own quirks and likes you to structure your objects in particular ways. If you don't want to manage the SQL your system uses, I would definitely recommend one of these approaches.

我来自一个后台数据库,而喜欢多一点在我的SQL的控制。特别是我喜欢我的interractions由存储过程来处理。我觉得这让我能够控制的优化这两个SQL好,但帮助我在​​一个更友好的方式管理数据库的安全性。为了适应这种方法,我建议像iBatis的( iBatis的)。 iBatis的是不是一个完整的ORM,而是一个简单的SQL映射。不足之处,以我的做法是,你需要编写大量的代码更(SQL),但我不介意的权衡。

I come from a database background, and prefer a bit more control over my SQL. In particular I like to have my interractions handled by stored procedures. I find this enables me to control both the SQL better for optimisation, but helps me manage database security in a more friendly manner. To accommodate this approach, I recommend something like iBatis (iBatis). iBatis isn't a full ORM, but rather a simple SQL mapper. The downside to my approach is that you need to write a lot more code (SQL), but I don't mind the trade-off.

这篇关于从SQL数据库表中的C#类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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