sorry I mean protected virtual void IncrementAmount( 2010/1/29 Fabio Maulo <[email protected]>
> version of NH ? > btw try to activate the WARN log-level and read the log file. > > protected void IncrementAmount( > > 2010/1/29 CassioT <[email protected]> > > But protected internal should work. Do you agree? Or does it work and >> I am doing something wrong? >> >> On 29 jan, 06:50, "Richard Brown \(gmail\)" <[email protected]> >> wrote: >> > If a method/property is marked as protected, than the NH proxy should be >> > able to intercept access. If there's any access to non-protected >> > private/internal members from outside the class, then the proxy is >> powerless >> > to intercept. >> > >> > http://broloco.blogspot.com/2008/01/nhibernate-identity-map-and-proxi. >> .. >> > >> > -------------------------------------------------- >> > From: "CassioT" <[email protected]> >> > Sent: Thursday, January 28, 2010 5:34 PM >> > To: "nhusers" <[email protected]> >> > Subject: [nhusers] Re: Proxy and property modification >> > >> > >> > >> > > Hi Richard, >> > >> > > Now I think I found the problem. I have a function IncrementAmount >> > > (decimal value). This function was protected internal and changing it >> > > to public it will work, even if the property Amount is private set. >> > >> > > So I think that the problem has relation to the Internal restriction. >> > > I don't know why since the function is marked as protected internal >> > > and not only as internal. To give you a clear look I'll write a >> > > similar code here: >> > >> > > public class Foo >> > > { >> > > public virtual decimal Amount { get; private set; } >> > >> > > protected internal void IncrementAmount(decimal value) >> > > { >> > > this.Amount += value; >> > > } >> > > } >> > >> > > public class Bar >> > > { >> > > public Foo Foo = new Foo(); >> > > } >> > >> > > Bar mapping: >> > > <many-to-one name="Foo" column="Foo_Id" class="Foo" not-null="true" / >> > >> > > var bar = s.Get<Bar>(10); >> > > bar.Foo.IncrementAmount(1); >> > >> > > TESTS RESULTS FOR THE ABOVE CODE: >> > >> > > Modifying the property: >> > >> > > protected internal void IncrementAmount(decimal value); >> > >> > > public virtual decimal Amount { get; private set; } // NOT OK >> > > public virtual decimal Amount { get; protected set; } // NOT OK >> > > public virtual decimal Amount { get; set; } // OK >> > >> > > Modifying the function: >> > >> > > public void IncrementAmount(decimal value); >> > >> > > public virtual decimal Amount { get; private set; } // OK >> > > public virtual decimal Amount { get; protected set; } // OK >> > > public virtual decimal Amount { get; set; } // OK >> > >> > > Modifying the mapping: >> > >> > > <many-to-one name="Foo" column="Foo_Id" class="Foo" not-null="true" >> > > fetch="join" /> // ALWAYS OK - Even with internal >> > >> > > So yes, I think this behavior has relation with the internal >> > > restriction. What do you think? >> > >> > > Thanks >> > >> > > On 28 jan, 06:48, "Richard Brown \(gmail\)" <[email protected]> >> > > wrote: >> > >> I think we need to see the code that modifies the Amount property. >> > >> > >> If the property is protected, it has to be inside a method of the >> class >> > >> (or >> > >> one of its subclasses). >> > >> > >> -------------------------------------------------- >> > >> From: "CassioT" <[email protected]> >> > >> Sent: Thursday, January 28, 2010 5:04 AM >> > >> To: "nhusers" <[email protected]> >> > >> Subject: [nhusers] Re: Proxy and property modification >> > >> > >> > Hi Richard, >> > >> > >> > Like I said, take: >> > >> > >> > public virtual decimal Amount { get; protected set; } >> > >> > >> > Anything that I try to put in Amount is denied. If Amount == 0 and >> I >> > >> > try something like Amount = 5, Amount will not be modified. >> > >> > >> > But like I said before, without the protected restriction or using >> > >> > fetch="join" (many-to-one association) it works >> > >> > >> > I tested the same code with pure classes (No NHibernate >> interaction), >> > >> > just to see if it was a .NET problem, and of course, it worked. >> > >> > >> > Thanks >> > >> > >> > On Jan 27, 8:19 pm, "Richard Brown \(gmail\)" >> > >> > <[email protected]> wrote: >> > >> >> Hi, >> > >> > >> >> Can you show the code that modifies the object? (accesses the >> > >> >> mutator) >> > >> > >> >> Thanks, >> > >> >> Richard >> > >> > >> >> -------------------------------------------------- >> > >> >> From: "CassioT" <[email protected]> >> > >> >> Sent: Wednesday, January 27, 2010 7:38 PM >> > >> >> To: "nhusers" <[email protected]> >> > >> >> Subject: [nhusers] Proxy and property modification >> > >> > >> >> > Hi all. >> > >> > >> >> > I have an entity that has a property that is defined like this: >> > >> > >> >> > public virtual decimal Amount { get; protected set; } >> > >> > >> >> > I don't know why but I can't modify it. The value never change. >> > >> > >> >> > I found two ways to fix it. >> > >> > >> >> > 1) Don't use the proxy version (fetch="join") - Never mind >> > >> >> > 2) Remove the protected restriction >> > >> > >> >> > Am I doing something wrong or do I have any other alternative? >> > >> > >> >> > I tried to access="field" too. >> > >> > >> >> > Thanks >> > >> > >> >> > -- >> > >> >> > You received this message because you are subscribed to the >> Google >> > >> >> > Groups >> > >> >> > "nhusers" group. >> > >> >> > To post to this group, send email to [email protected]. >> > >> >> > To unsubscribe from this group, send email to >> > >> >> > [email protected]<nhusers%[email protected]> >> . >> > >> >> > For more options, visit this group at >> > >> >> >http://groups.google.com/group/nhusers?hl=en. >> > >> > >> > -- >> > >> > You received this message because you are subscribed to the Google >> > >> > Groups >> > >> > "nhusers" group. >> > >> > To post to this group, send email to [email protected]. >> > >> > To unsubscribe from this group, send email to >> > >> > [email protected]<nhusers%[email protected]> >> . >> > >> > For more options, visit this group at >> > >> >http://groups.google.com/group/nhusers?hl=en. >> > >> > > -- >> > > You received this message because you are subscribed to the Google >> Groups >> > > "nhusers" group. >> > > To post to this group, send email to [email protected]. >> > > To unsubscribe from this group, send email to >> > > [email protected]<nhusers%[email protected]> >> . >> > > For more options, visit this group at >> > >http://groups.google.com/group/nhusers?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "nhusers" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<nhusers%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/nhusers?hl=en. >> >> > > > -- > Fabio Maulo > > -- Fabio Maulo -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
