472,127 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

CacheManager Fails to Save DataColumn DataType Change

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

Oct 19 '05 #1
0 1577

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by JC Voon | last post: by
1 post views Thread by Jay Balapa | last post: by
3 posts views Thread by DaveP | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.