문제

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.

도움이 되었습니까?

해결책

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");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top