1. Cross two ObjectContext : attach + changeObjectState
ProductCategory product;
using(AdventureWorksEntities ent=new AdventureWorksEntities())
{
product = ent.ProductCategories.FirstOrDefault();
product.Name += "123";
}
using (AdventureWorksEntities ent = new AdventureWorksEntities())
{
ent.ProductCategories.Attach(product);
ent.ObjectStateManager.ChangeObjectState(product, EntityState.Modified);
ent.SaveChanges();
}
ProductCategory newProduct=new ProductCategory()
{
Name = "Bikes1234",
ProductCategoryID = 1,
ModifiedDate = DateTime.Now
};
using(AdventureWorksEntities ent=new AdventureWorksEntities())
{
var product = ent.ProductCategories.FirstOrDefault();
ent.ProductCategories.ApplyCurrentValues(newProduct);
ent.SaveChanges();
}
3. ApplyOrginalValue
4.Cross WCF service (serialization and de-serialization): self tracking + ApplyChanges
5.WCF Data Service: AttachedTo