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")));
});