ContentManager.Query returns NULL

Topics: Troubleshooting
Sep 29, 2011 at 2:59 PM

Hello,

I've got next query:

orchardServices.ContentManager.Query<DepartmentPart, DepartmentPartRecord>().List();

Which always returns NULL then I expect Parts. In that time code like:

departmentRepository.Table().ToList();

Successfully returns Records.

What can be wrong?

Thanks

Coordinator
Sep 29, 2011 at 6:17 PM

I don't know, maybe your part is not a content part of DepartmentPartRecord? Hard to say with so little information.

Sep 30, 2011 at 7:02 AM

Sorry, my department record contains 2 another records.

Not department, but the same:

public class EmployeePartRecord : ContentPartRecord
{
    public virtual UserPartRecord UserPartRecord { get; set; }
    public virtual ExtendedUserPartRecord ExtendedUserPartRecord { get; set; }

}
In database this looks like one table with two foreign keys to 'child' tables.

So, I think my problem somewhere on Part side, cause repository actualy returns Record.

Sep 30, 2011 at 1:43 PM

Solved, my Driver use wrong Part in ContentPartDriver<>

Sep 30, 2011 at 2:39 PM

Interesting, as I understand ContentPartDriver<> used to register my Part in container. Is it right?
In that time Driver used to display my Part as a Shape. Is it right?

So, my question is: if I want to store not displayable data and use services (for example, calculation) I must create Driver just to register my Part?

Coordinator
Sep 30, 2011 at 7:21 PM

mmh, no. Your part is registered in a content type by altering the type in a migration.