0

I'm trying to do the following:

   var query = session.QueryOver<BaseEntity>()
                    .JoinAlias(x => x.FirstChild, () => FirstChildAlias)
                    .JoinAlias(x => x.SecondChild, () => SecondChildAlias)
                    .JoinAlias(() => SecondChildAlias.ListOfElementsChild, () => ListOfElementsChildAlias)
                    .Where(() => FirstChild.Text == "value 1")
                    .And(() => ListOfElementsChildAlias.Text =="value2");

How can I make constraints on the inner child which is of type List!? how can I get all BaseEntity elements that has a list with at least one child in the list having it's Text value equal to "value2"?

4

1 回答 1

0

这是对我有用的等效解决方案:

                var query = session.CreateCriteria<BaseEntity>("BaseEntity")
                                   .CreateCriteria("BaseEntity.FirstChild", "FirstChild")
                                    .Add(Restrictions.Eq("FirstChild.Text", firstChildTextValue))
                                   .CreateCriteria("BaseEntity.SecondChild", "SecondChild")
                                   .CreateCriteria("SecondChild.ListOfElementsChild", "ListOfElementsChild")
                                    .Add(Restrictions.Eq("ListOfElementsChild.Text", listOfElementsChildTextValue))
                                    .List<BaseEntity>(); 
于 2013-08-23T07:23:45.833 回答