Create a Blog EntryQuery fetching entries created by a user, either anonumously or not anonymously?

Vote:
 

Hello,

We're struggling a little bit with getting the following issue working. What we'd like to do is to, in one query using BlogHandler.GetQueryResult, retrieve BlogEntries created by a certain user, either anonymously (AnonymousAuthor) or not anonymously (UserAuthor). So far we've had to do two queries and then combine the result from these queries but we'd really like it if it's possible to do this in one query?

Here's the code for this:

            AnonymousAuthorCriterion anonymousCriteria = new AnonymousAuthorCriterion();
            anonymousCriteria.User = new UserCriterion();
            anonymousCriteria.User.ID = new IntegerCriterion();
            anonymousCriteria.User.ID.Value = anonymousAuthor.User.ID;
            EntryQuery entryQueryAnonymous = new EntryQuery();
            entryQueryAnonymous.Author = anonymousCriteria;
            entryQueryAnonymous.Created = new DateTimeCriterion();
            entryQueryAnonymous.OrderBy.Add(new CriterionSortOrder(entryQueryAnonymous.Created, SortingDirection.Descending));
            int anonymousCount;
            EntryCollection entriesAnonymous = BlogHandler.GetQueryResult(entryQueryAnonymous, page, pageSize, out anonymousCount);
            
            UserAuthorCriterion userCriterion = new UserAuthorCriterion();
            userCriterion.User = new UserCriterion();
            userCriterion.User.ID = new IntegerCriterion();
            userCriterion.User.ID.Value = userid;
            EntryQuery entryUser = new EntryQuery();
            entryUser.Author = userCriterion;
            entryUser.Created = new DateTimeCriterion();
            entryUser.OrderBy.Add(new CriterionSortOrder(entryUser.Created, SortingDirection.Descending));
            int userCount;
            EntryCollection entriesUser = BlogHandler.GetQueryResult(entryUser, page, pageSize, out userCount);

We've tried using CriteriaGroups and stuff but without any success, is there anybody out there who can help us?

Best regards

Martin

#38199
Apr 01, 2010 15:34
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.