Friday, September 12, 2008

Data Access Layer adding custom classes

When you create DataTables, the custom code is generated as an XML Schema Definition file, or .xsd.  If you right-click the definition for your DataTable in the Solution Explorer you can see the generated markup.  

This is useful to know, because while the autogenerated content does its job fine as is, you can add further stubs of code to modify Data Access operations or customize your results.  I did this by creating a new class file in the App_Code folder.  The new class file is a partial class that allows me to perform a custom method on a Row within a Table once the row has been instantiated.  This is a handy technique to cleanly procedureize a complex filter operation.  

More info on this technique is available at asp.net.

No comments: