简体   繁体   中英

The object cannot be attached because it is already in the object context

im trying to update a record in the database and it errors, i know the entry is there

            Order od = null;
            od = _session.Single<Order>(x => x.OrderId == OrderId);
            if (od != null)
            {
                od.PricePaid = svm.price;
                _session.Update(od);
                _session.CommitChanges();

but im getting

The object cannot be attached because it is already in the object context. An object can only be reattached when it is in an unchanged state.

Help please :)

省略代码的_session.Update(od)部分,它应该可以工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM