0

我的代碼是。爲什麼在實體框架5中成功修改了分離的實體?

class Program 
     { 

      static NorthwindEntities context = new NorthwindEntities(); 

      static void Main(string[] args) 
      { 
     Order updateorder = new Order() { OrderID = 10256, ShipCountry = "444", ShipCity = "tehran" };    
       update(updateorder); 
      } 


      static public void update(Order updateorder) 
      { 

       context.Entry<Order>(updateorder).State = EntityState.Modified; 

       context.SaveChanges(); 

      } 
     } 

請幫幫我,我感到困惑,爲什麼脫離實體在數據庫

回答

1

調用context.Entry<Order>(updateorder)重視的對象EF修改。