Question

Imagine I have C1, C2 and C3 classes. Suppose we can have string dummy = c1.ContainerC2.ContainerC3.Prop1. Is there any restriction that does not allow me to create an alias directly from C3 without having other classes in the criteria? For example:

DetachedCriteria criteria = DetachedCriteria.For<T>("root");
criteria.CreateAlias("ContainerC2.ContainerC3", "alias_abcdef");

I have problems with it. It generates SQL query that has following error message:

The multi-part identifier "alias_cont1_.HotelName" could not be bound.

Was it helpful?

Solution

You can't go to the ContainerC2 directly with CriteriaAPI. Instead you should do the folloing:

DetachedCriteria criteria = DetachedCriteria.For<T>("root");
criteria.CreateCreteria("ContainerC2")
        .CreateAlias("ContainderC3", "alias_abcdef");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top