开发者

NHibernate Restriction.IN doesn't work with IList

开发者 https://www.devze.com 2023-02-15 21:18 出处:网络
We are using NHibernate.Have 2 Classes Parent class which contains IList of Child Classes. From the table I have to get all the Parents that have certain Child elemnts.My code is as follows:

We are using NHibernate. Have 2 Classes Parent class which contains IList of Child Classes.

From the table I have to get all the Parents that have certain Child elemnts. My code is as follows:

String[] childs= { "Child1", "Child2" };
ICriteria criteria = Session.CreateCriteria(typeof(**Parent**));
criteria.Add(Restrictions.In("Roles", **childs**));
return c开发者_高级运维riteria.List<Parent>() as List<Parent>;

This is throwing "NHibernate.QueryException : Cannot use collections with InExpression" Error.

Can someone please help.


I believe here is your answer you need add alias to child Cannot use collections with InExpression

0

精彩评论

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

关注公众号