Hi,
I have this problem:
When I try to implement Ayende's complex searching found at:
http://ayende.com/Blog/archive/2006/12/07/ComplexSearchingQueryingWithNHibernate.aspx

with the object graph:
Person:
           M:1 Address:
                              M:1 Street:
                                              M:1 Place:
                                                              M:1
Country
I get the following error: NHibernate.QueryException: Cannot use
subqueries on a criteria without a projection.

I am doing this:
public List<Person> Find()
{
    DetachedCriteria query = DetachedCriteria.For<Person>();
    AddAddressQuery(query);
}

private void AddAddressQuery(DetachedCriteria query)
{
     DetachedCriteria addressQuery = null;
     if (!String.IsNullOrEmpty(SearchParams.HouseNumer))
     {
         addresaQuery = DetachedCriteria.For<Address>();
         addresaQuery.Add(Restrictions.Eq("HouseNumer",
SearchParams.HouseNumer));
     }

     this.AddStreetQuery(ref addressQuery);
     if (addressQuery != null)
     {
         query.CreateCriteria("Address1",
"address1").Add(Subqueries.Exists(addressQuery));
     }
}

private void AddStreetQuery(ref DetachedCriteria query)
{
    DetachedCriteria streetQuery = null;
    if (this.SearchParams.StreetId.HasValue)
    {
        streetQuery = DetachedCriteria.For<Street>();
        streetQuery .Add( Restrictions.Eq("Id",
this.SearchParams.StreetId.Value));
    }

    if (streetQuery != null)
    {
        query = query ?? Query.CreateCriteria("Address1");
        query.CreateCriteria("Street",
"street").Add(Subqueries.Exists(streetQuery ));
    }
}

What Am I doing wrong?
Please help


-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to