Created
July 26, 2015 03:53
-
-
Save snippe/9c51a82cd81215e3256d to your computer and use it in GitHub Desktop.
DbContext Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ObjectContext objectContext = ((IObjectContextAdapter)entities).ObjectContext; | |
Employee emp1 = new Employee() { EmployeeName = "Employee 1" }; | |
Employee emp2 = new Employee() { EmployeeName = "Employee 2" }; | |
entities.Employees.Add(emp1); | |
entities.Employees.Add(emp2); | |
entities.SaveChanges(); | |
objectContext.Detach(emp1); | |
emp1.EmployeeName = "Employee 1 newName"; | |
emp2.EmployeeName = "Employee 2 newName"; | |
entities.SaveChanges(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment