To answer my own questions.
1) The LINQ statement brought my original collection out as a Queryable type collection. If I converted into a List collection type before binding it to the DataGridView right at the beginning I didn't have any problems when I manipulated the data into different collections as they were
all of the List collection type.
2) LINQ statements are defaulted to deferred that means the query is only executed when you start to loop through it. This way there is little overhead as the objects aren't cached. The .ToList() and .ToArray() methods make for an immediate execution that caches the data as a collection of objects.
See working code below:
This is the property defined at the form level:
private List<vwTblStruct> str;
This is the initial data extraction from the SQL server:
str =
(from s in evokeDb.vwTblStructs
where s.tableisn == tblisn
orderby s.order
select s).ToList();
grdStruc.DataSource = str;
This is the data manipulation code before it databinding it back to the DataGridView:
grdStruc.DataSource = null;
var tmp1 = str.ToList();
foreach(var ord in tmp1)
{
if (ord.ord == v)
{
ord.ord = i;
break;
}
}
var tmp =
(from s in tmp1
orderby s.ord
select s).ToList();
short order = 1;
foreach (var s in tmp)
{
s.order = order;
s.ord = (decimal)(order + 0.5);
order++;
}
str = tmp;
grdStruc.DataSource = str;
tmp = null;
tmp1 = null;
I'm open to any suggestions and/or better ways to do accomplish the same result.