【发布时间】:2021-04-07 14:44:45
【问题描述】:
在解决上一个问题Is there a way to Clone one or many Entities (records) in Code 的所有工作后,我想清理它并使其更有用/可重用。到目前为止,我正在决定 如何 使用内容类型字段 names 来复制/添加字段,因此 foreach 中的 attribute.Key 位于 Attributes 上。我需要的是知道实体字段的类型;表示字符串、数字、超链接、实体等
所以我想要 if(AsEntity(original).FieldType == "HyperLink") { do this stuff } 之类的东西。我已经探索了 API 文档,但还没有发现如何获取信息。有可能吗?
我确实发现 attribute.Value 有一个我可以用来回答大多数问题的 Type,但是 Hyperlink 和 String 都显示了 System.String。
这里依次是字符串、超链接、实体和数字:
atts: ToSic.Eav.Data.Attribute`1[System.String]
atts: ToSic.Eav.Data.Attribute`1[System.String]
atts: ToSic.Eav.Data.Attribute`1[ToSic.Eav.Data.EntityRelationship]
atts: ToSic.Eav.Data.Attribute`1[System.Nullable`1[System.Decimal]]
那么有没有办法从实体或其属性或对象/方法/属性的其他路径中获取答案作为字段类型名称?或者是否有某种包装器可以让我处理(转换为/从)超链接?我对其他想法持开放态度。由于 fields.Add() 与“FieldType”不同,这将非常有用。
【问题讨论】:
标签: razor dotnetnuke 2sxc