6.4 Adding Custom Information
The DataSet contains a
PropertyCollection that is exposed through the
ExtendedProperties property. This collection allows a
user to add custom information to the
DataSet such as the date and time when the
DataSet should be refreshed. The following example
sets an extended property indicating that the
DataSet should be refreshed in 20 minutes:
ds.ExtendedProperties.Add("RefreshDateTime",
DateTime.Now.AddMinutes(20).ToString());
The following code can then check that value to see if the
DataSet needs to be refreshed:
if(DateTime.Now>Convert.ToDateTime(
ds.ExtendedProperties["RefreshDateTime"].ToString( ) ))
{
// ... code to refresh the DataSet
}
Extended properties must be of type String, or
else they will not persist when the DataSet is
written as XML.
The DataTable, DataColumn,
DataRelation, and Constraint
objects also have a similar collection of extended properties.
|