I think the problem is you can't guarantee which order the conventions
are applied, so it is probably best to also put an acceptance criteria
on the Cascade All to ignore the CompanyType:

public void Accept(IAcceptanceCriteria<IManyToOneInspector>
criteria)
        {
            criteria.Expect(x => x.Class != typeof(CompanyType));
        }

Plus I'm not sure if this is your actual code but you need to implement
IReferenceConvention as well on your CompanyConvention class.

HTH

Mart

-----Original Message-----
From: fluent-nhibernate@googlegroups.com
[mailto:fluent-nhibern...@googlegroups.com] On Behalf Of Centrium
Sent: 16 September 2009 20:31
To: Fluent NHibernate
Subject: [fluent-nhib] Cascading


Hi

Apolgies upfront if I misunderstand the concepts of cascading, however
I am wondering how to achieve the following.

I want to see all cascading to ALL by default, so I have created a
convention class called CascadeAll (see below), however I want to
override this behaviour or a target basis, and want to turn off
cascading for a particular classtype, which I was attempting with the
2nd snippet of code. However I cant get it too work, I can either have
all or none but not a mixture.

Thanks

Cent

public class CascadeAll : IHasOneConvention, IHasManyConvention ,
IReferenceConvention
    {
        public void Apply(IOneToOneInstance instance)
        {
            instance.Cascade.All();
        }

        public void Apply(IOneToManyCollectionInstance instance)
        {
            instance.Cascade.All();
        }

        public void Apply(IManyToOneInstance instance)
        {
            instance.Cascade.All();
        }
    }

public class CompanyConvention : IReferenceConventionAcceptance

        {
        public void Apply(IManyToOneInstance instance)
        {
            instance.Cascade.None();
        }

        public void Accept(IAcceptanceCriteria<IManyToOneInspector>
criteria)
        {
            criteria.Expect(x => x.Class == typeof(CompanyType));
        }
        }



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to