Hey, I am trying to alter an attribute of an object. I am setting it to the value of that same attribute stored on another table. There is a one to many relationship between the two. The product end is the one and the versions is the many. Right now, both these methods that I have tried have set all the products returned equal to the final version object. So, in this case they are all the same. I am not sure where the issue lies. Here are my two code snipets, both yield the same result.
int x = 1
IEnumerator<Product> ie = productQuery.GetEnumerator();
while (ie.MoveNext())
{
ie.Current.RSTATE = ie.Current.Versions.First(o => o.VersionNumber == x).RSTATE;
x++;
}
and
foreach (var product in productQuery)
{
product.RSTATE = product.Versions.Single(o => o.VersionNumber == x).RSTATE;
x++;
}
The versions table holds information for previous products, each is distinguished by the version number. I know that it will start at 1 and go until it reaches the current version, based on my query returning the proper number of products.
Thanks for any advice.
Ok, so apparently it is altering all of them because product has a unique Identity column, so when I modify one instance of it, it changes them all. So, looks like it is back to the drawing board.