您需要查看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