.NET 中的 SQL 和 Oracle 最佳实践

发布于 2024-10-01 14:41:05 字数 268 浏览 2 评论 0原文

我想知道使用 .Net 中的 Oracle 和 SQL 的最佳实践是什么。

优先事项:免费解决方案、查询性能、可重用代码。

例如,对 Oracle 和 SQL 使用相同的 LINQ 查询将会很漂亮。但据我所知,LINQ2SQL 仅适用于 Sql、实体框架 - 没有 Oracle 提供程序(例如我不想从 Codeplex 购买和使用)、nHibernate - 所以我需要近似于纯查询的性能。

我的 .NET 兄弟,你在项目中使用什么? :)

感谢您的经验。

I wanna to know what best practices would be used to work with Oracle and SQL from .Net.

Precedences : free solution , performance of queries, reusable code.

For example, will be beautiful to use the same LINQ queries to Oracle and SQL. But as far as I know LINQ2SQL is only to Sql, entity framework - no oracle provider(for example I don't want buy it and use from Codeplex), nHibernate - so I need performance that is approximated to pure query.

What do you use in your projects my .NET brothers? :)

Thanks for your experience.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

℡Ms空城旧梦 2024-10-08 14:41:05

我会使用 NHibernate企业库数据访问应用程序块

这是一个显示如何使用它的链接。
使用 Microsoft Enterprise Library 数据访问应用程序块 - 第二部分

另一种形式是简短教程。
企业库数据访问应用程序块入门

简而言之,NHibernate< /code> 是一个 ORM(对象关系映射)工具,可让您使用 XML 文件将面向对象的类映射到基础数据表,无论您使用什么基础数据存储。只需使用到数据存储的连接字符串对其进行配置,并为其提供正确的 .NET 数据提供程序即可使其完全正常工作。

另一方面,企业库的数据访问应用程序块是传统 ADO.NET 的一种包装器,以简化其使用。您可以命名连接字符串并打开与这些底层命名数据库/连接字符串的连接。一旦您掌握了该库的Database 对象及其配置功能,就没有什么可以阻止您访问数据。

这有帮助吗?
您需要我可以帮助您的更多详细信息吗?

编辑 #1

.NET 中的任何内容都不会执行“纯 SQL 查询”,因为 .NET 是托管代码。另外,在对数据库进行查询之前,您必须考虑连接开销和身份验证。

编辑 #2

这里是 NHibernate 支持的数据库列表:
NHibernate 支持的数据库

我似乎无法轻松使用 EntLib DAAB 查找(快速)支持的数据库列表,但这是我迄今为止已经使用过的数据库:

  1. Oracle 8i、9i 和 10g(请使用本机 Oracle .NET 数据提供程序以获得更好的性能和行为)
  2. SQL Server 2005/2008
  3. SQLite
  4. Microsoft Access

还支持许多其他内容。

I would either use NHibernate or Enterprise Library and the Data Access Application Block.

Here's a link where is shown how to use it.
Using Microsoft Enterprise Library Data Access Application Block – Part II

And another one under the form of a brief tutorial.
Get Started with the Enterprise Library Data Access Application Block

In short, NHibernate is an ORM (Object-Relational Mapping) tool that lets you map, using XML files, your object-oriented classes to underlying data tables, no matter what underlying datastore you're using. Suffice to configure it with a connection string to your datastore and provide it with the right .NET data provider to make it work altogether.

On the other hand, Enterprise Library's Data Access Application Block is a kind of wrapper over the traditional ADO.NET to simplify its use. You can name connection strings and open connections to these underlying named database/connection string. Once you will master the Database object of this library, and its configuration features, nothing will possibly stop you from accessing your data.

Does this help?
Do you need any further details which I could help you with?

EDIT #1

Nothing in .NET will perform as "pure SQL queries", as .NET is managed code. Plus, you have to consider the connection overhead and authentication before you can query against the database.

EDIT #2

Here for a list of supported databases with NHibernate:
Databases supported by NHibernate

I don't seem to be able to easily find (fast) a list of supported databases with the EntLib DAAB, but here's what I have already worked with so far:

  1. Oracle 8i, 9i and 10g (Please use native Oracle .NET Data Provider for better performance and behaviour)
  2. SQL Server 2005/2008
  3. SQLite
  4. Microsoft Access

Many others are supported also.

小嗲 2024-10-08 14:41:05

您还可以使用 ADO.NET 中的通用数据提供程序。请参阅 System.Data.Common 命名空间 - http://msdn.microsoft .com/en-us/library/system.data.common.aspx 和“在 ASP.NET 2.0 和 ADO.NET 2.0 中编写通用数据访问代码”http://msdn.microsoft.com/en-us/library/ms971499.aspx

You can also use the common data providers in ADO.NET. See System.Data.Common Namespace - http://msdn.microsoft.com/en-us/library/system.data.common.aspx and "Writing Generic Data Access Code in ASP.NET 2.0 and ADO.NET 2.0" http://msdn.microsoft.com/en-us/library/ms971499.aspx

甚是思念 2024-10-08 14:41:05

我喜欢存储过程,我认为它们给你带来了良好的性能和优雅。
nHibernate 也是一个不错的解决方案。

除了这两个,我不记得有什么可以推荐的了:)

I like Stored Procedures, I think they give you a nice performance and elegance.
nHibernate is also a nice solution.

Except for these two, I do not remember anything that I could recommend :)

牛↙奶布丁 2024-10-08 14:41:05

您可能想查看一下 nhibernate。它是一个开源 ORM,适用于大多数主要数据库。
http://nhibernate.info/

You may want to check out nhibernate. It is an open source ORM that works with most major databases.
http://nhibernate.info/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文