您需要查看CMS_Class數據庫表。找到你的類,然後是ClassFormDefinition字段,它具有顯示所有類型的字段的XML。
加載XML成的XmlDocument,則//字段[@柱= 「YourColumnName」]的selectNodes,下面是XML
<field column="CultureName" visible="true" columntype="text" fieldtype="CustomUserControl" system="true" columnsize="200" publicfield="false" guid="7b7c2f84-da09-4874-aade-a4d3b77b975d">
現在請注意的樣本,所述columntype是那種Kentico特定的命名,所以你必須做一個開關將其轉換爲.Net類或SQL數據庫。
switch (fieldType)
{
case "longtext":
case "text":
default:
dt.Columns.Add(fieldName, typeof(string));
break;
case "binary":
dt.Columns.Add(fieldName, typeof(byte[]));
break;
case "boolean":
dt.Columns.Add(fieldName, typeof(Boolean));
break;
case "date":
dt.Columns.Add(fieldName, typeof(DateTime));
break;
case "datetime":
dt.Columns.Add(fieldName, typeof(DateTime));
break;
case "decimal":
dt.Columns.Add(fieldName, typeof(Decimal));
break;
case "double":
dt.Columns.Add(fieldName, typeof(Double));
break;
case "integer":
dt.Columns.Add(fieldName, typeof(Int32));
break;
case "longinteger":
dt.Columns.Add(fieldName, typeof(Int64));
break;
case "timespan":
dt.Columns.Add(fieldName, typeof(TimeSpan));
break;
case "guid":
dt.Columns.Add(fieldName, typeof(Guid));
break;
}
是否可以通過REST API訪問CMS_Class數據庫表? – confusedandamused
是的,你可以通過'/ rest/cms.class/all'獲取數據 – rocky
@rocky當試圖使用/rest/cms.form/all或者/ rest/cms.class/all時, 403錯誤? – confusedandamused