开发者

NHibernate generates update statement for all columns

开发者 https://www.devze.com 2023-01-30 19:01 出处:网络
Does NHibernate always generate update for all 开发者_如何学运维columns? public class Person { public virtual int Id { get; set; }

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.


That is the default behavior, but you can make NH update modified columns only by adding dynamic-update="true" to your <class> mapping.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消