Friday, November 17, 2006

AppSettings and Visual Studio Test System

I started using Visual Studio Test System today, and quickly ran into a problem with my application's app.config not being available to my test project. But a few keystrokes brought me to Todd Girvin's AppSettings and Visual Studio Test System. Exactly what I needed to know.

Wednesday, November 01, 2006

Custom Properties on Typed Datasets

In .Net 2.0 it's possible to define custom properties for a typed Dataset and retain them when the code is regenerated, thanks to the wonders of partial classes. I was writing a UI prototype recently for a Windows application, and used typed Datasets and TableAdapters to speed up development.

It's always been possible to define an expression for a calculated column in a DataTable, using a syntax that I think is supposed to remind us of SQL. But you're limited in what you can put in there, restricted to a few defined functions. To pick one example, there is, as far as I can tell, no way to specify that the current date be used as one of the expression's operands.

This led me to writing a custom property for my typed DataRow, one that used some business rules about effective dates and anniversary dates to calculate a duration. In Object Explorer, this property looked like all the others. Could I use it in Windows databinding?

The answer appears to be "No", although I haven't found anything written about it one way or the other. But it won't appear in the Property window's field picker, and specifying it leads to an runtime error. I don't know the reason for sure, but I suspect it's because the object you're connecting your controls to when you bind to a DataTable is really a DataView. A custom property on the typed DataRow wouldn't be accessible through a DataRowView.

And this is a pity. When you're writing a little three-day minimum-investment project like my prototype, you want an easy, clean solution, one where you do the hard stuff once if at all and don't lock yourself into any particular architecture. A typed DataRow that could expose bindable custom properties would be a good stand-in for the custom business objects that it's too early in the project to create.