Hello,
I would like to know, if there are a analog for the Hibernate 's Java
approach in the .NET Framework.
As I understand Java's hibernate allows to conserve, and use the programmed
objects in the SQL relationnal databases's tables.
For .NET, there is somthing similar in LINQ. There is also available a
NHibernate. I am new in this things, can somebody advice me from where to
begin, and in general, maybe .NET has something more powerful to optimise
code's intercation with the database?..
/sergiu
The category of tools you are looking for is called "object-relational
mapping", or "O/RM".
LINQ is actually not an O/RM but a set of compiler extensions for C#
and VB.NET (and some class library extensions shipped with .NET 3.5,
such as the IQueryable interface).
Although LINQ serves also more general purposes, such as better
supporting the functional programming paradigm, the most popular
application of LINQ is using it for building query expressions, that
the C#/VB.NET compiler can parse, validate and compile either to IL
(evaluating the query in memory) or to an expression tree (providing
the means for a tool like an O/RM to translate the query into a
database platform specific SQL dialect).
O/RM tools for .NET can use LINQ as their query language, instead of
their own proprietary query language (which every pre-LINQ existing
tool has, like HQL in case of Hibernate/NHibernate).
Some benefits of a platform provided language such as LINQ over
proprietary query languages are
+) broad existing knowledge about the language in the developer
community (at least in a medium term time frame LINQ will be common
knowledge amongst VB.NET/C# developers)
+) the language can be used in different scenarios, not just for O/RM
(there are a number of APIs provided by MS and third parties, that
utilise LINQ, and the number is growing)
+) integrated IDE support (intellisense, refactoring, etc.) and
compile time checking (this is also true for O/RMs that use the Query
Object Pattern, however this is again proprietary and not remotely as
elegant/readable/convenient as LINQ)
Microsoft already provides a (free) basic O/RM supporting LINQ, called
Linq2Sql. (introduced with the release of .NET Framework 3.5 and
Visual Studio 2008), which is limited to support MS-SQL only.
Some O/RM vendors are already providing LINQ support (like our tool
Genome
http://www.genom-e.com), supporting also different database
platforms and providing more complex O/RM functionality than Linq2Sql.
Some other O/RM vendors are working on LINQ support (as far as I know
both LLBLGen and nHibernate are working on LINQ integration).
ADO.NET Entity Framework (EF), mentioned by Michael, is the next
generation of ADO.NET, Microsoft's abstraction for data access
under .NET. Unlike Linq2Sql, it is not (just) an O/RM, but also
abstracts the lower levels of data access, such as the relational data
model (called EDM=Entity Data Model) and the SQL query language
(eSQL). This is a major difference to the abstraction provided by
ADO.NET today, which is basically just wrapping how to connect to a
database (but the connection string is platform specific), sending
commands (but the commands you send, are platform specific SQL) and
receiving data (but the data types received are again platform
specific). On top of the EDM and eSQL, ADO.NET EF will provide several
APIs to access data, amongst them an O/RM called Linq2Entities.
Another interesting feature of EF is that it provides a plugable
provider model for database platform vendors, to translate eSQL to the
platform specific SQL dialect.
While LINQ (and O/RMs supporting LINQ) are released and available
today, the EF is said to be released some time in 2008. If I would
start a project today, I would not hold my breadth for EF, especially
since the basic concepts (like O/RM and LINQ) are already available
today and will not cause dramatic architectural changes in your
project, when EF is finally released.
When chosing an O/RM for .NET I would definitely look for LINQ
integration (either ready or almost ready), to be harnessed for the
future.
Then I would recommend to actually try out the products you have on
your short list in a PoC to verify it fits your development workflow
and architectural paradigms. In larger scale commercial projects
productivity related features like Visual Studio integration, error
reporting, support and documentation are also counting very much.
Greetings,
Christian