Andres Aguiar's Weblog

Right here, right now

Stories

DeKlarit 4.0 Released - CAB, WSE, VS2005, SQL2005, Layouts & More!

Last week we released DeKlarit 4.0.

I won't post the new feature list here, as you can read it in the website. What I will do is tell you about my favorite new features ;).

Gaston built a great platform-independent layout editor. We can now generate very sophisticated forms in Windows Forms or ASP.NET using the same metadata.

We added support for the Composite Application Block (and EntLib 2) which makes possible to customize DeKlarit generated Windows Forms applications without modifying the generated code.

Thanks to ASP.NET 2.0 great support for custom datasources, we can expose the full power of the generated business logic layer very easily to ASP.NET with a DeklaritDataSource. Most of the credit here goes to the ASP.NET team, as writing the DataSource is not that hard.

For SQL generation fans, we now can page hierarchical unnormalized views very efficiently. Let's say you want to retrieve the second page of the orders, including its order lines, and in the Orders headers you want to retrieve some fields from the Customers and Employees tables (but not all the fields), and in the Order lines you want to retrieve some fields from the Products table. We will execute two SQL sentences, here in its SQL 2005 syntax:

SELECT * FROM ( SELECT  TM1.[OrderID], T2.[CompanyName], TM1.[OrderDate], T3.[FirstName], TM1.[RequiredDate], TM1.[ShippedDate], TM1.[Freight],
TM1.[ShipName], TM1.[ShipAddress], TM1.[ShipCity], TM1.[ShipRegion], TM1.[ShipPostalCode], TM1.[ShipCountry], TM1.[CustomerID], TM1.[EmployeeID],
TM1.[ShipVia], ROW_NUMBER() OVER (ORDER BY TM1.[OrderID] ) AS DK_PAGENUM   FROM ((dbo.[Orders] TM1 LEFT JOIN dbo.[Customers] T2 ON T2.[CustomerID] = TM1.[CustomerID]) LEFT JOIN dbo.[Employees] T3 ON T3.[EmployeeID] = TM1.[EmployeeID])  ) AS DK_PAGE WHERE
DK_PAGENUM BETWEEN 81 AND 160

SELECT T1.[OrderID], T3.[ProductName], T1.[UnitPrice], T1.[Quantity], T1.[Discount], T1.[ProductID] FROM ((dbo.[Order Details] T1 INNER
JOIN  ( SELECT * FROM ( SELECT TM1.[OrderID], ROW_NUMBER() OVER  ( ORDER BY TM1.[OrderID]  ) AS DK_PAGENUM   FROM dbo.[Orders]  M1) AS DK_PAGE WHERE
DK_PAGENUM BETWEEN 81 AND 160)  TMX ON TMX.[OrderID] = T1.[OrderID]) INNER JOIN dbo.[Products] T3 ON T3.[ProductID] = T1.[ProductID]) ORDER
BY T1.[OrderID], T1.[ProductID]

As you can see, the nested level joins with the right page of the upper level so it just retrieves the children rows for the headers retrieved in the first query.

This works for any number of hierarchical levels,with simple and compound primary keys, including filtering conditions in each level. I have no doubts that some .NET code generators/O/R mappers support this, but I'm pretty sure most of them don't ;).

 

Comments

No Comments