如何通过路由到模型从 Umbraco 检索数据?

问题描述 投票:0回答:1

我拿到节点了

   var l=  UmbracoContext.Current.ContentCache.GetByRoute("1080/companies")

该节点为doctype公司列表

如何将节点序列化为all. generated.cs中的公司类列表??

umbraco
1个回答
0
投票

它应该已经是 Company 类型。您应该能够将其转换为您的模型类型,例如:

var l =  UmbracoContext.Current.ContentCache.GetByRoute("1080/companies") as Company;

或者

var l =  (Company)UmbracoContext.Current.ContentCache.GetByRoute("1080/companies");

假设生成的类名为 Company。

© www.soinside.com 2019 - 2024. All rights reserved.