I revised my first answer as it did not answer the question.
I still don't have an answer, after trying the code below.
It works fine as far as I can see.
static DataSet ds = new DataSet();
public static void LoadCache()
{
DataTable dt = ds.Tables.Add();
dt.Columns.Add("key", typeof(int));
dt.Columns.Add("name", typeof(string));
dt.Rows.Add(0, "Donald");
dt.Rows.Add(0, "Duck");
dt.Rows.Add(1, "Mickey");
dt.Rows.Add(1, "Mouse");
HttpRuntime.Cache.Insert("myCache", ds, null, Cache.NoAbsoluteExpiration,
Cache.NoSlidingExpiration, CacheItemPriority.High, null);
}
public DataSet GetXMLData()
{
if (HttpRuntime.Cache["myCache"] == null)
{
LoadCache();
}
return (DataSet)HttpRuntime.Cache["myCache"];
}
public void GetData()
{
DataView dv = GetXMLData().Tables[0].DefaultView;
dv.RowFilter = "key=0";
DataTable dtTemp = dv.ToTable();
dtTemp.Columns.Add("sort");
}
private void SomeFunction()
{
GetData();
GetData();
GetData();
}
As I don't know the structure of your dataset, I cannot do much more testing.
There are also other differences that might be a factor.