pyhavaim wrote:
Code:
public class User:BusinessObject<User>
{
public String name
{
get{ return _name;}
set {
_name=value;
base.PropertyHasChanged("Name");
}
}
}
And in BusinessObject PropertyHasChanged will invoke
session.SaveOrUpdate(this);
Also I have made some extra control functoins like SuspendSave(boolean) and things like that, when I need to do something more complicated
pyhavaim,
This code seems a little odd in the NHibernate context. NHibernate does the work you just described automatically. So it looks like you created your own framework to duplicate part of the NHibernate framework.
Keep in mind what a previous poster said. Save/Update/SaveOrUpdate are not methods which are used to save/update to a database. It's used to add the objects to the session (unit of work). That doesn't mean that a database call won't be made at that point (it may) but we really don't control when those calls are made.
Whenever an object is loaded into an NHibernated session it will create an internal object to store the state of the object when it was loaded so that when flush is called it can compare the current values and compare them to that of the initially loaded values. If a value has changed it will save that change to the database.
Writing a framework which does the same thing seems counterproductive.