2

I am using glass mapper and TDS code generation templates to generate models for my sitecore templates.

All working Good. But, If i have a multi-list field TDS templates are creating IEnumerable<Guid>. I want it to be IEnumerable<OtherSitecoreTemplate>. Its working if i manually change it. But next time when code is regenerated, all my changes will be lost.

Is there a better way to do this?


You can set a custom type on your multi-list field that will be used during code generation by setting the "Custom Data" property of the field in TDS:

Custom Data.

In your case, if you set this to "generic=Namespace.OtherSitecoreTemplate" the stock code generation templates for TDS will generate as IEnumerable<OtherSitecoreTemplate>

As an aside, this is where you'd set the type for Link fields. If you use the string "type=OtherSitecoreTemplate" it will strongly type the field to the value provided.

4

1 回答 1

11

您可以通过在 TDS 中设置字段的“自定义数据”属性,在多列表字段上设置将在代码生成期间使用的自定义类型:

自定义数据.

在您的情况下,如果您将其设置为“generic=Namespace.OtherSitecoreTemplate”,则 TDS 的股票代码生成模板将生成为IEnumerable<OtherSitecoreTemplate>

顺便说一句,这是您设置链接字段类型的地方。如果您使用字符串“type=OtherSitecoreTemplate”,它将强烈地将该字段键入到提供的值。

于 2015-03-30T12:32:09.177 回答