Wednesday, 14 December 2005

ADO.NET 2.0 TableAdapters

I'm starting to get my head around some of the new features of .NET 2.0. One that I'm finding quite useful is the generated TableAdapters that are part of the new DataSet designer.

One situation I've just come across is the idea of having a "CREATED" and "MODIFIED" column for all tables to assist in auditing. By default, the code generated for the TableAdapter will try to insert and update these columns. But we want these columns to be only modified by triggers inside the database itself! So how to you modify the TableAdapter to read but not update these special columns?

TableAdapter and Properties WindowIt turns out you can right-click on the TableAdapter heading to modify it's properties, including the InsertCommand and UpdateCommand.

Another way you can extend the TableAdapter is through partial classes.

No comments: