QueryException

Topics: Core, Troubleshooting, Writing modules
Developer
Apr 15, 2012 at 10:19 AM
Edited Apr 15, 2012 at 10:21 AM

I'm executing a query on a model that is 3 levels deep, using navigation properties:

public IEnumerable<ContactPart> GetContactsByClient(int clientId) 
{
return _contentManager.Query<ContactPart, ContactPartRecord>().Where(contact => contact.Office.Client.Id == clientId).List();
}


But this throws a "QueryException: could not resolve property: Client of: MyModule.Models.ContactPartRecord"

 The entities look like this:

public class ClientPartRecord : ContentPartRecord
{
    public virtual bool ReceiveNewsletter { get; set; }
}

public class OfficePartRecord : ContentPartRecord
{
    public virtual ClientPartRecord Client { get; set; }
}

public class ContactPartRecord : ContentPartRecord
{
    public virtual OfficePartRecord Office { get; set; }
}

So, each Client has multiple Offices, and each Office has multiple Contacts.
I want to list all contacts for a certain client using the above mentioned query.

I also tried this:

public IEnumerable<ContactPart> GetContactsByClient(int clientId)
        {
            //return _contentManager.Query<ContactPart, ContactPartRecord>().Where(x => x.Office.Client.Id == clientId).List();

            return _contentManager
                .Query<ContactPart, ContactPartRecord>()
                .Join<OfficePartRecord>().Where(x => office.Client.Id == clientId)
                .List();
        }

But that just returns an empty list.

Any hints or pointers to existing modules that have similar queries?

Thanks.

 

 

Nov 14, 2012 at 9:44 PM

Did you ever get this figured out, I am running into the same issue.