C# .NET - out of memory error in updating data linq to datatable in c#

Asked By Amrita Gaur on 22-Feb-13 02:18 AM
I have an application where i am updating the datatable with linq , the table is having lakhs of rows , but it causes out of memory exection.

The piece of code  is as follow



var resultPos = (from ps in _dtPS.AsEnumerable()




where ps.Field<string>("refType") == "O"




join


pos


in _dtPositions.AsEnumerable()




on new


{

refID = ps.Field<


int>("refID")


}



equals new


{

refID = pos.Field<


int>("Open_id")


}



select new { ps, pos });




// var row;




Parallel.ForEach(resultPos, row =>


{

row.pos.SetField<


double>("Quantity", Math.Abs(row.pos.Field<double>("Quantity")) - Math.Abs((row.ps.Field<double>("qty"))) * Math.Sign(row.pos.Field<double>("Quantity")));


});


Danasegarane Arunachalam replied to Amrita Gaur on 22-Feb-13 03:39 AM
Try this one

http://stackoverflow.com/questions/4593959/releasing-linq-to-sql-resources-to-avoid-outofmemoryexception