This is a method for add/update an entity using Self Tracking Entities, what is the equivalent using POCO?
public Hero SaveHero(Hero hero)
{
using (WarEntities model = new WarEntities())
{
if (hero.ChangeTracker.State == ObjectState.Added)
{
model.Heroes.AddObject(hero);
model.SaveChanges();
hero.AcceptChanges();
return hero;
}
else if (hero.ChangeTracker.State == ObjectState.Modified)
{
model.Heroes.ApplyChanges(hero);
model.SaveChanges();
return hero;
}
else
return null;
}
}