Problem setting Not.LazyLoad() on OneToManyCollectionInstance
Hi,
I've been trying to work out a problem where I try to set instance.Not.LazyLoad() from an IHasManyConvention, and lazy="true" appears in the mappings instead of the expected lazy="false".
This is the code I have in my convention:
public class HasManyConvention : IHasManyConvention
{
public void Apply(IOneToManyCollectionInstance instance)
{
if(switch) instance.Not.LazyLoad();
}
}
If the switch is true, it puts lazy="true" in my hbms, otherwise it doesn't put anything in there.
It seems that Conventions/Instances/OneToManyCollectionInstance.cs is declaring its own private new bool nextBool rather than using the superclass' protected bool nextBool (from CollectionInstance). The result of this is that when you call Not, it sets nextBool=false on the OneToManyCollectionInstance object then LazyLoad() uses the CollectionInstance's nextBool which is still set to true.
Simply removing
private new bool nextBool;
from OneToManyCollectionInstance.cs makes it behave as I'd expect it to. Removing the new Not property would probably work too.
Link to OneToManyCollectionInstance.cs: http://github.com/jagregory/fluent-nhibernate/blob/master/src/Fluen...
Thanks,
Cameron
2 Posted by James Cracknell on 21 Jul, 2010 04:40 PM
I will confirm this issue.
Has anyone come up with a temporary workaround that doesn't involve using mixed mapping paradigms or maintaining a fork?
Support Staff 3 Posted by James Gregory on 22 Jul, 2010 11:00 AM
You could send us a pull request with the fix...
Support Staff 4 Posted by Paul Batum on 25 Jul, 2010 09:04 AM
I've received the pull request and applied it to my dev branch (along with
an extra test).
5 Posted by David on 12 Aug, 2010 03:03 AM
I noticed an issue with setting Not.Inverse() in a HasManyConvention. (The generated xml still showed inverse="true")
I'm guessing that'd be a related issue...