Using the data layer API to query your kentico Database

Source: Internet
Author: User

Original post address: http://devnet.kentico.com/Knowledge-Base/API-and-Internals/Using-the-data-layer-API-to-query-your-Kentico-dat.aspx

This article describes how to make use of the kentico API to perform complex queries or create generic code that queries both system and Custom tables.

For system tables related to objects with info classes, you can access the data using providers, such as userinfoprovider (for instance, to retrieve a userinfo object to access data from cms_user table ).

Database Table API documentation

You can also make use of the data layer API. The CMS. dataengine class can allow you more
Flexibility than using providers. You can perform more complex queries, generate queries within code, and query both system and Custom tables.

Code examples for 5.5r2

Code examples for 6.0

Code example for 7.0

For more complex queries and queries against custom tables, you can use the executequery method. see the last example in the above documentation. the query you call must exist in the cms_query table. by default any custom tables will have
Least A selectall method.

Keep in mind that from 6.0 on, you need to use a querydataparameters object, but in 5.5r2 or earlier, you wocould use a generic object. in either case, you will want to establish a general connection:

Generalconnection Cn = connectionhelper. getconnection ();

Then execute the query using that connection:

CN. executequery (...)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.