直接贴示例代码吧
1 public static void UpdateOwnerAndCondo(int buildingID, ActionupdateAction) 2 { 3 Building building = new Building(); 4 building.ID = buildingID; 5 using (CafContext context = CafContext.Create()) 6 { 7 context.Configuration.ValidateOnSaveEnabled = false; 8 context.Entry (building).State = EntityState.Unchanged; 9 updateAction(building);10 context.SaveChanges();11 }12 building.ID = buildingID;13 }