In my content management system, i allow the user to define their
own 'objects' (e.g. Staff Member) and then i provide templated
data entry forms to let them populate instances of these objects.
It's aimed at non-techies so i have my own datatypes called 'Text'
which maps to System.String, 'Number' maps
to System.Double etc. I also have a few custom data
types called 'File' and 'Image' to allow the user to add files or
images to an instance of the object.
This business of doing column-mapping was ok as long as my data
types had obvious .Net equivalents, but 'Image' doesn't in my case. i'm
only storing a reference to the image, but in my application, it's not
to be treated just as a System.String. When the user is creating
a new object with an 'Image' field in it, i want to display a file
upload instead of a textbox, and when i go to display the object on the
site, I want to display a html IMG tag with the SRC set to the value of
the image field.
The dataset is serialised into an xml file with the schema embedded.
i needed to find some way of encoding my own custom data type
information into the dataset that would persist into the xml
file. I looked through the VS intellisense and found the
'ExtendedProperties' data column property. This property allows
you to plug in any number of key/value pairs of information to each
column. This was exactly what i needed, so i added in a pair
with something like "MyDataType=Image" for each column. This
persisted nicely into the xml file as follows:
<xs:element name="Photo" msprop:MyDataType="Image" type="xs:string" minOccurs="0" />
Note that the official type of the field is "xs:string",
because it contains a path to the image. but now it also has the custom
data type tagged on to the column definition. in this respect, i'm glad
to see that MS have provided a very elegant and flexible framework.