Change Set 20446 - AutoScaffold Foreign Key GridView Columns

March 26, 2007 14:36

I've added a new enhancement to AutoScaffold which I believe many of you will find useful: Foreign Key values in the grid. With this addition, you will now see the "name" column in the foreign key table for a particular value instead of the key value from the local table. It even supports sorting!

This feature is accomplished via the addition of a new Query method, ExecuteJoinedDataSet(). This method iterates through the table schema columns constructing a dynamic SQL SELECT query. For each foreign key that it finds, it adds an INNER JOIN on the foreign key table, selecting the second column from that table as the name field (following our positioning convention).

Because join syntax is more complicated and picky than a straight select, I would not yet call this feature bullet-proof, so please report any problems you encounter. In testing this, I have already encountered a large issue regarding the qualification of column names in databases like Adventureworks that use periods in table names.

Once the kinks have been worked out, I'll extend the functionality to the other two scaffold variants.

Other Changes & Enhancements

  • Retrieving foreign key table names no longer requires requerying the database schema on every invocation.
  • Added OrderBy overloads to Query that take TableColumns as parameters. Since the TableColumns provider access to provider methods, you should use these overloads instead of passing a column name, particularly if you are using multiple or non-SQL Server providers.
  • Improved formatting of the TableColumn.DisplayName property. 

Download


0 Comments
Actions: E-mail | Permalink | Comment RSSRSS comment feed

Related posts

Comments are closed