Query on ContentPartRecord not returning results, but returns results if I to .ToList() and query on the ContentPart

Topics: General, Troubleshooting
Jul 9, 2014 at 11:58 PM
I'm having an issue where I'm getting zero elements returned by a query. However if I to a ToList() on my base query, then perform the query on the ContentPart rather than on the ContentPartRecord, I get more than one result. Also I can see in the database that the Group_Id column has values which match what I'm querying.

I'm not seeing any errors in the logs. Similar code as this has worked for me before so I'm baffled as to why it's not working.
public class GroupContentPartRecord : ContentPartRecord
    public virtual int Group_Id { get; set; }


var containersBaseQuery = _contentManager.Query(VersionOptions.Latest)

// This code returns ZERO items
var groupContentContainers = containersBaseQuery.ForPart<GroupContentPart>()
    .Where<GroupContentPartRecord>(gc => gc.Group_Id == groupId)
    .Select(gc => gc.ContentItem);

// This code returns MORE THAN ONE item
var findEm = test.Where(x => {
    var g = x.As<GroupContentPart>().Group;
    return g != null && g.Id == groupId;
Jul 10, 2014 at 6:45 AM
I don't see what's wrong, but if you attach a module showing the issue (including a database) then I can look into it. You must be doing something wrong, but I need more context to see it.