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.



ADO. NET in a Nutshell
ADO.NET in a Nutshell
ISBN: 0596003617
EAN: 2147483647
Year: 2005
Pages: 415

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net