Selecting by specific elements in a list in HQL
public class Cat()
{
public int ID { get; set; }
public string Name { get; set; }
public Cat Child { get; set; }
}
Now I'm trying to select a cat by his child, so the HQL should be something like this:
SELECT cat FROM CAT as cat
WHERE cat.Child = {"Any value or subsearch"}
But if I alter the Cat class to have a one-to-many reference:
public class Cat()
{
public int ID { get; set; }
public string Name { get; set; }
public IList<Cat> Children { get; set; }
}
The HQL will now look like this (I'm trying to select by a specific child in the list)
SELECT cat FROM CAT as cat
WHERE {"Any value or subsearch"} IN elements(Children}
My question is, Can I make the second query to be similiar in the order to the 开发者_StackOverflow社区first one
Something like this:SELECT cat FROM CAT as cat
WHERE Children CONTAIN {"Any value or subsearch"}
Thanks [=
You are probably looking for something like this:
select cat from Cat cat
join cat.Children child
where child.Something is true
Neither HQL nor Linq are great for dynamically constructed queries.
I suggest you use Criteria instead.
精彩评论