Taking advantage of Linq trying to make a neater update code on the provided DataSet-Based approach :
The Code I’m trying is :
ListProducts.ForEach( product =>
{
DsProducts.TblProductsRow row = Ds1Products.TblProducts.First( p => p.Name == product.Name);
row.Price = Product.Price ;
});
Adapter.Update(Ds1Products, "TblProducts");
Not sure weather I needed parameters here or not, I haven’t defined any yet.
Cause wanted to use the "Typed" facilities of it.
The Data Adapter is initialized and filled.
Notes :
-
It does not work right now , Gotten Error here :
"Sequence contains no matching element" -
Wanted to Replace the foreach with
Linq's Selectif possible( Try it to be neat and Linqy as possible )
-
its in SQL CE (Shouldn’t be a problem here on most cases)
This is hopefully what you need:
Edit: Here’s the strong typed DataSet way(almost identical):
By the way,
List.ForEachis not Linq, it existed already in .NET 2.0 hence prior to Linq.