Panasonic Youth rob sanheim writes about software, business, ruby, music, stuff and things



Posted
11 January 2006 @ 6pm

Tagged
Less Code, Object Oriented, Patterns, Rails, Software

Discuss

Neward’s paper on the OR mismatch and LINQ

Ted Neward recently posted an extensive paper comparing various OR solutions from over the years, including JDBC, SQLJ, and ActiveRecord. Of course, the paper finished up by showing .NET's upcoming solution with LINQ and how it "hopes to take a large step forward in minimizing the object-relational mismatch." It allows you to code something like this (this retrieves Order, OrderDetails and Product in the Northwind db in one request):

C#:
  1. var custs = (
  2.   from c in db.Customers
  3.   where c.City == "London"
  4.   select c )
  5.   .Including(c => c.Orders
  6.     .Including(o => o.OrderDetails
  7.       .Including(od => od.Product)));
  8.  
  9. foreach (var cust in custs) {
  10.   foreach (var ord in cust.Orders) {
  11.     foreach (var orderDetail in ord.OrderDetails) {
  12.       Console.WriteLine("CustomerID {0} has an OrderID {1} " +
  13.                         "with ProductID {2} that has name {3}.",
  14.                             cust.CustomerID, ord.OrderID,
  15.                             orderDetail.ProductID,
  16.                             orderDetail.Product.ProductName);
  17.     }
  18.   }
  19. }

Even with a higher level of abstraction such as Spring's JdbcTemplate, I can imagine it would be quite a bit nastier. I'd love to see something like this come to Java, either in the next JDBC but more likely via Hibernate or Spring. Go read the paper and let Ted know what you think.


No Comments Yet


There are no comments yet. You could be the first!

Leave a Comment

MacBook Pro announced: “4-5x faster than the PowerBook G5″ So if WebWork uses DWR & Dojo, and Struts is becoming WebWork…