API Questions on Kentico API.
Version 5.x > API > build a custom querry View modes: 
User avatar
Member
Member
wtzeng-micro-datanet - 8/29/2011 4:24:40 PM
   
build a custom querry
Hi,
do you have example of how to use SqlGenerator.GenerateQuerry? or an example how to manually create custom query in the CMS_Query.
I try to do a custom querry for COM_Address to get the all the billing address of a customer.

Thanks

User avatar
Member
Member
kentico_michal - 8/30/2011 2:37:25 AM
   
RE:build a custom querry
Hello,

Please take a look at following code snippet that shows how you can create a new query and assign it to a given class specified in the QueryClassId property:

CMS.SettingsProvider.Query q = new CMS.SettingsProvider.Query();

q.QueryName = <name>;
q.QueryClassId = <classId>;
q.QueryType = QueryTypeEnum.SQLQuery;
q.RequiresTransaction = <true/false>;
q.QueryText = <query text>;

CMS.SettingsProvider.QueryProvider.SetQuery(q);


For more information I would like to point yout to the API reference Kentico CMS API

Best regards,
Michal Legen