Hi All,
I am using Microsoft.ApplicationBlocks.Cache.CacheManager to persist a
System.Data.Dataset object. This Dataset object has a DataTable that is
created from an existing DataTable using the Clone() method. Before I
add the new DataTable to the DataSet, I change the DataType of a
DataColumn from System.String to System.Int64. I then add data to the
new table and then add it to the DataSet. Then DataSet is then added to
the Cache. However, when I retrieve the DataSet from the Cache, the
DataColumn whose DataType I changed, reverted back to System.String. Is
this a bug? Am I doing something wrong? Here is a sample of the code
process.
<code>
DataSet ds = null;
DataTable oldTable = GetSomeTable();
DataTable newTable = oldTable.Clone();
newTable.TableName = "New Table";
newTable.Columns[0].DataType = System.Int64;
// Note: at this point the DataType has indeed been changed to
System.Int64.
// Populate with data
DataRow newRow = null;
DataRow[] selectedRow = oldTable.Select(SomeSQLSelectString);
foreach(DataRow oldRow in selectedRow)
{
newRow = newTable.NewRow();
newRow.ItemArray = oldRow.ItemArray;
newTable.Rows.Add(newRow);
}
// Add to DataSet
ds.Tables.Add(newTable);
// Checking again at this point, DataType is still System.Int64;
CacheManager.GetCacheManager().Add("NewDataSetKey" , ds);
// Retreive DataSet from Cache
DataSet dsIncorrectColumnType =
CacheManager.GetCacheManager().GetData("NewDataSet Key");
// Fails
Debug.Assert(dsIncorrectColumnType.Tables["New
Table"].Columns[0].DataType = System.Int64);
</code>
Regards,
Brig R. Lamoreaux