Retrieving CustomTable Data in Kentico 8

John Fu asked on March 3, 2014 21:34

I've got a CustomTable. And I'm trying to write a controller that will retrieve the data from this custom table. I can't seem to do so because the CustomTableProvider object does not appear to be available as I can when using ASPX Templates in Kentico 7. I'm thinking that perhaps because the structure of the code has changed quite a bit.

Do you have an example of how I can retrieve data from custom tables for Kentico 8? I have got it working by creating a new query under the custom table to select all, and then using the DataQuery object to retrieve the data that way, but there has to be a better way than that, no?

Thanks, John.

Recent Answers


Juraj Ondrus answered on March 4, 2014 03:18

Hi,

First of all I would like to mention that the version you have is just for preview and not for development. It will stop working at some point and there won't be any upgrade or transition possible to the final Kentico 8 release.

In your case, you could be using CustomTableItemProvider.GetItems(className) which is returning ObjectQuery. I think this should be what you are looking for.

Best regards,
Juraj Ondrus

0 votesVote for this answer Mark as a Correct answer

John Fu answered on March 4, 2014 03:22

Hi Juraj,

Thanks for the tip regarding no upgrade or transition possible. I'll discuss that with my colleagues.

About using CustomTableItemProvider, that class does not seem to be available for use in an MVC Controller located in the App_MVC project.

0 votesVote for this answer Mark as a Correct answer

John Fu answered on March 30, 2014 17:28

I found out that the MVC_Project does not reference CMS.CustomTables by default. Which is why CustomTableItemProvider was not available.

0 votesVote for this answer Mark as a Correct answer

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