This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.Sometimes there may be the need to store a loaded entity in a place that outlives the session that retrieved it. Later on, you need to associate this entity with a new session, in order to continue using it; for this, you tipically use the Merge method. When you do this, however, you must use a new reference to the entity returned by this method: Order order = HttpContext.Current.Session["order"] as Order;
Order savedOrder = session.Merge<Order>(order);
savedOrder.Customer = session.Load<Customer>(Int32.Parse(this.customerDropDownList.SelectedValue));
Read more: Development With A Dot
QR:
Order savedOrder = session.Merge<Order>(order);
savedOrder.Customer = session.Load<Customer>(Int32.Parse(this.customerDropDownList.SelectedValue));
Read more: Development With A Dot
QR:
0 comments:
Post a Comment