Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>in mapping if you use FluentNHibernate</p> <pre><code>public UserMap : ClassMap&lt;User&gt; { public UserMap() { Where("id = currentid"); // always bring back the most recent } } // in Userrepository public void Update(User user) { var clone = user.Clone(); session.Evict(user); // to prevent flushing the changes var newId = session.Save(clone); session.CreateQuery("UPDATE User u SET u.currentid = :current") // &lt;-- hql .SetParameter("current", newId) .ExecuteUpdate(); } </code></pre> <p>objectgraphs are a lot trickier with this simple code. I would then do one of the following:</p> <ul> <li>use NHibernate.Envers to store auditing information for me</li> <li>explicitly creating new entities in BL code</li> </ul> <p>i once saw an append-only-model doing something like the following</p> <pre><code>// UserBase is there to ensure that all others referencing the User doesnt have to update because user properties changed class UserBase { public virtual int Id { get; set; } public virtual ICollection&lt;PersonDetails&gt; AllDetails { get; private set; } public virtual PersonDetails CurrentDetails { get { return _currentDetauils; } set { _currentDetauils = value; AllDetails.Add(value); } } // same as above public virtual ICollection&lt;ConfigDetails&gt; AllConfigs { get; set; } } class Order { public virtual int Id { get; set; } public virtual UserBase User { get; set; } public virtual IList&lt;OrderDetail&gt; AllDetails { get; private set; } public virtual IList&lt;OrderDetail&gt; ActiveDetails { get; private set; } public virtual void Add(OrderDetail detail) { AllDetails.Add(detail); ActiveDetails.Add(detail); } public virtual void Delete(OrderDetail detail) { detail.Active = false; ActiveDetails.Remove(detail); } } class OrderDetail { public virtual int Id { get; set; } public virtual Order Parent { get; set; } public virtual bool Active { get; set; } } class OrderMap : ClassMap&lt;Order&gt; { public OrderMap() { HasMany(o =&gt; o.AllDetails); HasMany(o =&gt; o.ActiveDetails).Where("active=1"); } } // somewhere public void UpdateTaxCharge(OrderDetail detail, TaxCharge charge) { var clone = detail.Clone(); clone.TaxCharge = charge; detail.Order.Delete(detail); detail.Order.Add(clone); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload