So That is What the Custom Data Property is for. #Sitecore #Hedgehog #TDS and Glass Mapper Model Generation.

Glass and TDS makes our development life easier so we should try and use every feature we can. Right? One of my favorite features is generating a list of Glass models instead of GUIDS. A lot of you probably know this, but there is always times where someone does not. I wanted to document this so this can help others.

Select the field that is a Treelist or whatever multi list field.

In the properties under Code Generation you need to specify the type of list you want returned with model.

In my case:

type=IEnumerable<Feature.SectionLink.Models.sitecore.templates.Feature.SectionLink.SectionLink>.

Now Glass will auto generate and you will get the actual Glass Item Model instead a list of GUIDS.

[SitecoreType(TemplateId=ISectionLinksConstants.TemplateIdString)]

public partial class
SectionLinks  : GlassBase, ISectionLinks

       {

///
<summary>

 /// The Section List field.

            ///
<para></para>

                           ///
<para>Field Type: Treelist</para>          

                           ///
<para>Field ID: e09af999-37fa-42a3-98b7-1ffb802413c2</para>

                           ///
<para>Custom Data: type=IEnumerable<Feature.SectionLink.Models.sitecore.templates.Feature.SectionLink.SectionLink></para>

                           ///
</summary>

                           [global::System.CodeDom.Compiler.GeneratedCodeAttribute(“Team Development for Sitecore – GlassItem.tt”, “1.0”)]

                           [SitecoreField(ISectionLinksConstants.Section_ListsFieldName)]

                           public
virtual
IEnumerable<Feature.SectionLink.Models.sitecore.templates.Feature.SectionLink.SectionLink> Section_Lists  {get; set;}

       }

In my controller I just call it this way and I have my list to run through the ForEach:

viewModel = sitecoreservice.Cast<ISectionLinks>(Sitecore.Context.Item,inferType:true).Section_Lists.ToList();

So that is it. Let me know if there is something else we can do with this property. I would like to know.

3 thoughts on “So That is What the Custom Data Property is for. #Sitecore #Hedgehog #TDS and Glass Mapper Model Generation.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s