EF中的填加:
T_user user = new T_user(); user.f_username = "jll"; user.f_password = "34"; user.f_passed = 1; //EF增加 BlogDb.T_user.AddObject(user); BlogDb.SaveChanges(); //EF修改 var user1 = (from u in BlogDb.T_user where u.id == 1 select u).FirstOrDefault<T_user>(); user1.f_username = "lyquuu"; BlogDb.SaveChanges(); //EF修改 T_user user2 = new T_user() { id = 2, f_username = "mvc123", f_passed = 1, f_password = "123456" }; BlogDb.T_user.Attach(user2); BlogDb.ObjectStateManager.ChangeObjectState(user2, System.Data.EntityState.Modified); BlogDb.SaveChanges(); #region 主从实体增加 Customer customer = new Customer() { UserName = "jll12344", Address = "广东", Phone = "332", Email = "222" }; BlogDb.Customer.AddObject(customer); Order o1 = new Order(); o1.ID = Guid.NewGuid(); o1.Customer = customer; o1.OrderContent = "323"; o1.SubTime = DateTime.Now; BlogDb.Order.AddObject(o1); BlogDb.SaveChanges(); #endregion