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), nHib开发者_JAVA技巧ernate - so I need performance that is approximated to pure query.
What do you use in your projects my .NET brothers? :)
Thanks for your experience.
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:
- Oracle 8i, 9i and 10g (Please use native Oracle .NET Data Provider for better performance and behaviour)
- SQL Server 2005/2008
- SQLite
- Microsoft Access
Many others are supported also.
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
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 :)
You may want to check out nhibernate. It is an open source ORM that works with most major databases. http://nhibernate.info/
精彩评论