Restrict columns for child pages

Dmitry Bastron asked on August 5, 2016 10:49

Hi community!

I'm trying to restrict number of columns loaded for child pages with API call like this:

var children = DocumentHelper.GetDocuments()
    .Path("/MyPath")
    .FirstOrDefault()
    .Children;

For this query Kentico loads 109 columns for child pages. How can I specify something like .Columns("columnList") here?

Correct Answer

Dawid Jachnik answered on August 5, 2016 11:53

I'm also almost sure that one of these sql's are very similar to that one which generates the node.Children

 var children = DocumentHelper.GetDocuments()
                    .Columns("FirstColumn", "SecondCOlumn")
                    .WhereEquals("NodeParentID", node.NodeID);

or

var children = DocumentHelper.GetDocuments()
                .Columns("FirstColumn", "SecondCOlumn")
                .Path(node.NodeAliasPath, PathTypeEnum.Children);
0 votesVote for this answer Unmark Correct answer

Recent Answers


Dawid Jachnik answered on August 5, 2016 11:05

Hello,

Try with this

var children = DocumentHelper.GetDocuments()
                    .Columns("FirstColumn", "SecondCOlumn")
                    .Path("/MyPath", PathTypeEnum.Children);
0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on August 5, 2016 11:14

Hi David,

Thank you for your answer, this is a working solution but would not help me. In this part of my project I'm writing the code dealing with single TreeNode object, i.e. in the concrete function I have a TreeNode for which I should load child elements:

public void ComputeChildRecords(TreeNode node)
{
    var children = node.Children.ToList(); // This leads to SQL query and I want to specify columns here 
}
0 votesVote for this answer Mark as a Correct answer

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