I have a class B which contains a string 'b'. I also have a class A which contains a list of Bs (ILi开发者_C百科st) called list.
I would like to find all distinct objects of A which contain B objects that contain the string 'bla' in the string 'b'.
Is this possible?
Thanks.
Christian
Sure:
session.CreateQuery(@"
select distinct a
from A a
join a.Bs b
where b.b = 'bla'
").List<A>();
If the relationship is bidirectional (i.e. B has a reference to A), it's even easier:
select distinct b.A
from B b
where b.b = 'bla'
I assumed you meant B.b equals 'bla'. If you meant bla is part of B.b, you can use the LIKE
operator just like in SQL
精彩评论