CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeffrey Palermo [MVP]

Software management consultant and CTO, Headspring Systems

We'll see Microsoft's OR Mapper soon - level 100

Many long-time Microsoft developer hold fast to the "all data access must be stored procedures" thought, and that was, at one time, the guidance from Microsoft.  Soon we'll see the Object-relational mapper from Microsoft in the form of Linq for Entities.  I drove up to the North Dallas .Net User Group yesterday and visited with Scott Guthrie on the topic.  Microsoft has tried a few times before at creating an OR mapper, but they've learned from past attempts and are releasing v1.0 of Linq as their entry into the ORM space.

I'm very much entrenched in the ORM space with NHibernate, but I'm interested in how Linq for Entities pans out.  From a cursory look, the mapping information is specified with attributes that are placed on the entity class.  I'm not sure if that's the only method for this, but I'm very much looking forward to the release.

An interesting tidbit demonstrated was the server-side paging of a Linq query.  For instance, the C# query: from customers select customer, you can specify to skip 10 and then return 10 (or any number) if you need to page through the resultset 10 at a time.  Linq will formulate the SQL query to get you exactly what you want.  Very nice.  Ayende, in the comments below gives an example of that with NHibernate.



Comments

Ayende Rahien said:

Paging with NHibernate: session.CreateQuery("from Post") .SetFirstResult(10) .SetMaxResults(10) .List();
# November 3, 2006 12:07 PM

Udi Dahan - The Software Simplist said:

O/R mapping is a poor fit for reporting like operations, in my opinion. It just wasn't really designed for it. On the other hand, I don't think that LINQ was designed to give me the polymorphic "get" that NHibernate does. The whole issue of mapping a class hierarchy, and getting back the appropriate object which special cases the behavior enables us to write true OO persistent objects. Paging, like reporting, is not something O/R mappers were designed to do well. Use LINQ for it.
# November 3, 2006 12:24 PM

Jeffrey Palermo said:

Ayende, thanks a bunch! I love my blog. It's better than a forum post! These are the kinds of things I love finding out.
# November 3, 2006 1:54 PM

Jeffrey Palermo said:

Udi, Yes, I can see how those are different paradigms. Up to this point, my team has been very happy with NHibernate (and I personally started using it about a year ago) including the little bit of reporting we do. The few times I have gotten into hairy querying situations, I've been able to hand-craft the query and return only the IDs of the objects I need to return. Then I ask NHibernate to get me those objects where the ID is "IN (. . .list. . .)"
# November 3, 2006 1:58 PM

Ayende Rahien said:

@Jeremy, You can get entities from a custom SQL query, using CreateSqlQuery() This saves a DB query. Although, when you need to do wierd stuff with the report, specifically, presenting this as something that is very different than the data / object model
# November 3, 2006 9:53 PM

Ayende Rahien said:

@Udi, I really disagree about thinks that O/R isn't supposed to do paging / reporting. Speaking specifically about NHibernate, it has a great support for both of those. These features are not usually covered in details in most tutorial, since they focused on getting stuff working in small measures, not the complex problems you find yourself facing 50% into a project.
# November 3, 2006 10:03 PM

Sam Gentile said:

Family morning at the Gentiles means the whole family watching Radiohead from 1994 while waiting for

# November 4, 2006 9:41 AM

Tom Dean said:

In web development, at least, paging is imperative to performance. Lack of decent paging with an OR/M wrapper is liking giving a mechanic all the tools he needs except a screwdriver.
# November 5, 2006 6:50 PM

Sam Gentile said:

Family morning at the Gentiles means the whole family watching Radiohead from 1994 while waiting for

# October 20, 2007 3:33 PM

About Jeffrey Palermo

Jeffrey Palermo is a software management consultant and the CTO of Headspring Systems in Austin, TX. Jeffrey specializes in Agile coaching and helps companies double the productivity of software teams. Jeffrey is an MCSD.Net , Microsoft MVP, Certified Scrummaster, Austin .Net User Group leader, AgileAustin board member, INETA speaker, INETA Membership Mentor, Christian, husband, father, motorcyclist, Eagle Scout, U.S. Army Veteran, and Texas A&M University graduate. Check out Devlicio.us!

This Blog

Syndication