Thursday, July 15, 2010

Saving objects using Entity framework

TableClass tableObject = new TableClass();
tableObject.property1 = "Hello";
tableObject.proeprty2 = "World";

// NOTE: make sure to use the same instance of entityContextObject which was used to populate the tableObject (e.g. updating back to database)
entityContextObject.AddToTableClass(tableObject);
entityContextObject.SaveChanges();

No comments: