Using TAKE with GetDocuments?

Simon Goldsmith asked on June 1, 2017 17:54

How do I use Take<> with GetDOcuments? Everytime I add in .Take(3) above .TypedResult it causes issues with my columns?

I am trying to only pull back 3 items for a repeater;

var caseStudies = DocumentHelper.GetDocuments("csm.casestudy") .Path("/work/%") .Culture(preferredCulture) .CombineWithDefaultCulture(CurrentSite.CombineWithDefaultCulture) .OnSite(CurrentSiteName) .Where(String.Format("(region like '%{0}%')", preferredRegion)) .Published() .OrderByDescending("Date") .TypedResult;

ShowcaseRepeater.DataSource = caseStudies;

Recent Answers


Peter M answered on June 1, 2017 18:06 (last edited on June 1, 2017 18:16)

Try to use TopN(3) with DocumentHelper

DocumentHelper.GetDocuments("csm.casestudy").TopN(3).Path ... or

caseStudies.Tables[0].AsEnumerable().Take(3)

2 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.