1.  How can NHibernate know that the instance is dirty & needs updating if it 
hasn't been retrieved from the DB?
2.  What if your setter has side effects, e.g.

   class SomeType {
       private SomeParentType _parent;

      public User Owner { get; protected set; }

     public SomeParentType Parent {                         // Denormalised for 
performance…
                set {
                                _parent = value;
                                this.Owner = _parent.Owner;
                }

/Pete


From: [email protected] [mailto:[email protected]] On Behalf Of 
merrycoder
Sent: 21 February 2014 14:26
To: [email protected]
Subject: [nhusers] Proxy m -> 1 assignment and lazy loading

Hi there

I want to update an instance without loading it first. this is accomplished by 
loading the proxy with session.load(), updating it's values and saving it.

var myinstance = session.Load<SomeType>(10);
myinstance.intproperty = 10;
session.Update(myinstance); //-> only update statement is sent to DB - ok!

This works fine with properties of primitive types, but as soon as I set a m -> 
1 relationship myinstance  will be fetched from DB:

var myinstance = session.Load(10);
myinstance.myparent = session.Load<SomeParentType>(20); //-> myinstance is 
fetched from DB! - nok!
session.Update(myinstance); //-> update statement is sent to DB

Can i prevent myinstance to be fetched? IMHO calling the setter of myparent 
should not fetch the instance.

Thanks
Stefan

--
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
To post to this group, send email to 
[email protected]<mailto:[email protected]>.
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to