I am working on Glassmapper 5 and I have baseType and derived type. I need to get derived type(IRich_Text_Section) property values by using basetype(I_PageSection). It is working fine in glassmapper4.
public partial interface IGlassBase
{
[SitecoreId]
Guid Id{ get; }
[SitecoreInfo(SitecoreInfoType.Language)]
Language Language{ get; }
[SitecoreInfo(SitecoreInfoType.Version)]
int Version { get; }
[SitecoreInfo(SitecoreInfoType.Url)]
string Url { get; }
[SitecoreInfo(SitecoreInfoType.Name)]
string ScItemName { get; }
[SitecoreItem]
Item ScItem { get; }
[SitecoreField("__Sortorder")]
string SortOrder { get; }
}
[SitecoreType(TemplateId=I_PageSectionConstants.TemplateIdString )]
public partial interface I_PageSection : IGlassBase
{
}
[SitecoreType(TemplateId=IRich_Text_SectionConstants.TemplateIdString )]
public partial interface IRich_Text_Section : IGlassBase , I_PageSection
{
[SitecoreField(IRich_Text_SectionConstants.Body_TextFieldName, Setting=SitecoreFieldSettings.InferType)]
string Body_Text {get; set;}
}
public ContentSectionViewModel Format(I_PageSection pageSection)
{
//I am able to get item from pageSection(id, Language,version). Now i need to get Body_Text value so used the below code and getting null value in section after casting.
**IRich_Text_Section section = pageSection as IRich_Text_Section;**
}
Getting null after assigning to IRich_Text_Section.
IRich_Text_Section section = pageSection as IRich_Text_Section;
Appreciated it anyone can help with this. Thanks in advance!!