Cool Kentico 8 Feature - Code Generation
Posted by Dave Conder on October 08, 2015
The DataQuery API was released as part of Kentico 8. This is an intuitive, fluent API that makes data operations easy. Both content and objects can be queried, and it can return strongly-typed or dataset objects. Behind the scenes, it generates SQL statements on the fly, similar to how Entity Framework or Linq-to-SQL works.
On top of the DataQuery API in Kentico 8.1, which does support strongly-typed objects, there is a tool built into doc types, custom tables, and forms that will generate the C# code necessary for fully functional, strongly typed object models.
Here's an example of the Code Generation screen:
The Page type (In Kentico 8.1, "Document Types" are now called "Page Types") and all of its properties are included in this code file. It can then be referenced like this:
/// Get news pages
InfoDataSet pages = DocumentHelper.GetDocuments()
// Get a news page
ContentArticle page = DocumentHelper.GetDocuments()
.Path("/Articles/" + aliasPath)
string title = page.AriticleTitle;
You can find out more about DataQuery here:
Dave Conder has been using technology to create value and solve problems for more than 15 years. His background includes technical management, network architecture and design, security, and application development. As CTO, Dave ensures that BlueModus always uses the best people, practices, and tools to deliver world-class digital marketing solutions.