Blinq, blinq, pimp my web app

Scott Guthrie has done a demo in his two part Tech Ed 2006 talk and also showed a demo of the Blinq prototype. Unfortunately I was not at TechEd, but he posted on it. Since Blinq is up on the Sandbox page of the ASP.NET website, I decided to check it out.


Blinq creates a website built on top of a SQL Server 2000 or 2005 database. It will generate three pages for every table in the database:



  1. List view for all records in the table.
    There is a GridView that allows you to sort, page, edit (in the grid), delete and go to related records in a child table.

  2. Details view for a single record
    Contains a DetailsView for viewing, links for editing and deleting.

  3. Insert page for inserting a single record
    Essentially same as details view, but has Insert and Clear Values links.

The data access logic is provided by DLinq, which is why the Linq CTP (May 2006) is required. The C:Program FilesMicrosoft ASP.NETBlinq contains most of the assemblies also installed for Linq. These are copied into the Bin folder of the website.



The website uses master pages for the layout, a sitemap for the navigation, aspx pages without any code, but with a ObjectDataSource (ODS) to provide the data. The ODS uses classes from two code files that are in the App_Code folder of the website. These contain the two parts for the DataContext derived class for accessing the data source, and two parts for every data entity per table.


One of the two .cs files is created by SqlMetal.exe from the Linq preview. This tool, which can also be run from the command-line generates a partial class for every table, taking into account the foreign keys to provide the relations between the classes. The other file, StaticMethods.cs, will add static CRUDy methods to each data entity class, such as GetAllProducts, GetProductsByCategory, Insert, Delete and Update (with optimistic concurrency checks). The code clearly indicates which of the static methods should or should not be edited with your own functionality.


The whole show starts when you run the Blinq.exe tool from the command-line. It’s pretty straight-forward, but to get you started, you could try to run this command on your Northwind database:


Blinq.exe /t:c:NorthwindWebSite /database:Northwind /vDir:Northwind


It will create all files inside the C:NorthwindWebsite, with a virtual directory in IIS. I had to set the ASP.NET runtime version for the website in IIS to 2.0 manually. You will see that you need to do the same if you get a configuration error, stating that the <system.codedom> element is not recognized inside your web.config. This is known behavior, because the created vdir will inherit the scriptmappings from the Default Website. Blinq does not alter these. You can read more about that here.


Go ahead and give it a spin. You might find some errors. For example, the delete on the Details View pages do not seem to work properly.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s