Reputation: 764
Does NHibernate always generate update for all columns?
public class Person { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual string Address { get; set; } } Person p = Session.Load(1); p.Name = "New Name"; Session.Flush();//Update for all columns, but I change only Name
Is it normal behavior for NHibernate or my mistake? I use Fluent NHibernate and AutoMapping.
Upvotes: 8
Views: 2714
Reputation: 52753
That is the default behavior, but you can make NH update modified columns only by adding dynamic-update="true"
to your <class>
mapping.
Upvotes: 11
Reputation: 24152
NHibernate always updates all mapped columns. This should be no trouble if the other columns didn't change, since on update the data has been previously pumped from the underlying datastore, so basically, it only reset the column values to their own orginal values. No problem about it.
If you want to override this behaviour, you need to implement the IInterceptor interface.
Upvotes: -2