Try our conversational search powered by Generative AI!

Confused by GetEntries


I just want to list blog entries between specific dates. But to do that from BlogHandler.GetEntries I have to set an IUser object for which the read status is checked - which won't work for anonymous users. If I use Blog.GetEntries instead it seems to ignore my data limitations completely. What to do?

Apr 09, 2010 15:01

"Data limitations" should be "date limitations" of course.

Apr 09, 2010 15:07

You can use the EPiServer Community query system to achieve this. This code snippet retrieves all blog entries created between January 6th, 2010 and April 1st, 2010:

            EntryQuery entryQuery = new EntryQuery();
            CriteriaGroup criteriaGroup = new CriteriaGroup();

            entryQuery.Created = new DateTimeCriterion();
            entryQuery.Created.Value = new DateTime(2010, 01, 06);
            entryQuery.Created.Operator = ComparisonOperator.GreaterThan;

            entryQuery.Created = new DateTimeCriterion();
            entryQuery.Created.Value = new DateTime(2010, 04, 01);
            entryQuery.Created.Operator = ComparisonOperator.LessThan;
            criteriaGroup.AddCriterion(LogicalOperator.And, entryQuery.Created);

            entryQuery.OrderBy.Add(new CriterionSortOrder(entryQuery.Created, SortingDirection.Descending));

            EntryCollection entries = QueryHandler.GetQueryResult(entryQuery);


Apr 09, 2010 20:29

Thanks for the tip, but I got it working using BlogHandler in the end so that I get caching and everything. It was possible to pass null for the IUser reference. The Blog.GetEntries call failed because it would filter down to a BlogHandler call where the flag "byPublishDate" would be false which probably messed things up since I'm interested in the creation date.

Edited, Apr 12, 2010 8:00
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.