开发者

Does DetachedCriteria/ICriteria have any restriction on join depth?

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:

DetachedCrit开发者_运维知识库eria 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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜