While you create this request in the code:
from xx in db.vwCustomizationHeaders
where xx.ProductID == pID
select new custHeader()
{
headIndex = headIndex++
}
It actually runs in the database. And the database cannot change the values ββin your code. Therefore, you cannot increase this local code value ( headIndex) from the database. (Also, as @Kirk Woll pointed out, itβs a very bad practice to change such values ββin the selection. The choice is to simply extract / create something and not change the state or create side effects.)
, , , select. :
headIndex += db.vwCustomizationHeaders.Count(ch => ch.ProductID == pID);
, vwCustomizationHeader, - :
lst = (from xx in db.vwCustomizationHeaders
where xx.ProductID == pID
select new custHeader()
{
SomeField = xx.SomeField,
AnotherField = xx.SomeOtherField
});
lst :
headIndex += lst.Count();