OfferItem offerItem;
using (Rainbow3Entities db = new Rainbow3Entities())
{
offerItem = db.OfferItem.First();
}
var prId = offerItem.ProductID;
var ofId = offerItem.OfferID;
offerItem.Name = "dummy";
using (Rainbow3Entities db = new Rainbow3Entities())
{
OfferItem offerItemFromDB = db.Set<OfferItem>().Find(offerItem.ProductID, offerItem.OfferID);
db.Entry<OfferItem>(offerItemFromDB).CurrentValues.SetValues(offerItem);
db.SaveChanges();
}
Sep 29, 2014
Entity Framework 6 - save changes with values from entity obtained out of context
When saving using Entity Framework changes in Db entity values for updating for existing Entity can be provided by helper SetValues:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment