Database Views

Jeffrey Schulz asked on June 3, 2016 04:41

I am new to Kentico, I can see the project I am working on using DocumentHelper.GetDocument to get custom page table data and CustomTableItemProvider.GetItems to get custom table data.

Is there a similar way to get data from a view that has been created in the database? If not what is the recomended way to implement connecting to the DB to query a view? I can see the views in the CMS under Database Object->Views.

Recent Answers


Brenden Kehren answered on June 3, 2016 05:01

You can use something like this:

DataSet ds = ConnectionHelper.ExecuteQuery("SELET * FROM VIEW_CMS_TREE_JOINED", new QueryDataParameters(), QueryTypeEnum.SQLQuery);

I'd recommend creating some parameters though to make sure you filter your data properly. Any particular data you're trying to get? If you see a view for it, there is most likely an API call already created for you to use.

0 votesVote for this answer Mark as a Correct answer

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