views:

32

answers:

0

Hi all,

When having the following model:

class Organisation {
}

class Insurance : Organisation {
    public int UZOVInumber {get;set;)
    ...
}

class HealthcareOffice : Organisation {
    public int UZOVInumber {get;set;)
    ...
}

class OtherOrganisation : Organisation {
    ...
}

You can see that 2 subclasses have the same propertyname (UZOVInumber). Now, I want to create a criteria based on that property.

Ideally there should be another subclass from Organisation which should be the superclass of both Insurance and HealthcareOffice, but that is not an option right now.

The classes are mapped as JoinedSubclass (table per subclass).

How can I create a criteria which makes it possible to search on UZOVInumber on both subclasses? I have the following code right now:

ICriteria crit = Session.CreateCriteria(typeof (Organisatie));
...other criteria...
if (!String.IsNullOrEmpty(search.Uzovi))
{
    crit.Add(Restrictions.Eq("UZOVInumber", search.Uzovi));
}

This works on just the UZOVInumber of one subclass. The generated sql joins all subclasses(which is correct) and the UZOVInumber field is selected twice (one for each subclass). However, the given value is only compared with the first column (and thus only with the first subclass).

How can I make it search both subclasses without changing my model? (And is it possible without changing property-names?)

Thanks in advance!