0

我的代码是。

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();

            }
        }

请帮助我,我很困惑为什么在数据库中修改了分离的实体

4

1 回答 1

1

调用context.Entry<Order>(updateorder)将对象附加到 EF。

于 2013-03-08T14:26:05.340 回答