Bhavesh Jadav

Bhavesh Jadav

  • 1k
  • 1.1k
  • 6.8k

Webchase data was changed after execute LINQ query.

Sep 21 2018 7:04 AM
Hello friends,

I faced issue to get original data from Web cache/Session/Tempdata which I store on it.

I have two data set dsProducts and dsSearchdata.
dsProducts > table1 having 200 rows
dsSearchdata > table1 having 500 rows and table2 having 300 rows.

Now I store dsSearchdata on Webcache/Session/Tempdata.

Now I perform LINQ on between both DataSet Tables and get filer rows from dsSearchdata.
Take filer table and store it on the dataset of its index, at that time original data are changed from Web cache/Session/Tempdata.

Code Snippet:
  1. Session["MapData"] = dsSearchdata;    // dsSearchdata is DataSet  
  2.   
  3. for (int i = 1; i < dsSearchdata.Tables.Count; i++)  
  4. {  
  5.      var mapping = (from tbl1 in dsSearchdata.Tables[i].AsEnumerable()  
  6.                 join tbl2 in dsCategoryProducts.Tables[0].AsEnumerable()  
  7.                 on tbl1.Field<int>("ProductId") equals tbl2.Field<int>("ProductId")  
  8.                 select tbl1).CopyToDataTable();  
  9.                   
  10.      if (mapping.Rows.Count > 0)  
  11.      {  
  12.          DataTable dt = new DataTable();  
  13.          dt = mapping;  
  14.          dsSearchdata.Tables[i].Clear();  
  15.          dsSearchdata.Tables[i].Merge(dt, true);  
  16.      }        
  17.   
  18.     // Here if I check my original data on Session["MapData"] then it was changed as per the result of the above query.  


I don't know what's happening, please help me.

Thanks.