c# - GlassMapper - GetItem<T>() method is failing to get item as specific type -


i'm trying item using glassmapper follow:

var mycustomobj=sitecorecontext.getitem<imy_custom_type>(itemid); 

but mycustomobj null.

when try item iglass_base object, works:

var mycustomobj=sitecorecontext.getitem<iglass_base>(itemid); 

edited: here how imy_custom_type looks:

    /// <summary>     /// imy_custom_type interface     /// <para></para>     /// <para>path: /sitecore/templates/user defined/###/pages/my custom type</para>         /// <para>id: dfacd744-0cf8-4917-922c-4baeb07dfe35</para>        /// </summary>     [sitecoretype(templateid=imy_custom_typeconstants.templateidstring, automap = true )] //, cachable = true     public partial interface imy_custom_type : iglassbase , global::sc.global.models.templatemodels.base_templates.imetadata, global::sc.global.models.templatemodels.base_templates.ibase_background_image     {         /// <summary>         /// custom field.         /// <para></para>         /// <para>field type: multilist</para>               /// <para>field id: 43388fa5-a02a-425d-ae31-d94a12860748</para>         /// <para>custom data: </para>         /// </summary>         [sitecorefield(imy_custom_typeconstants.mycustomfieldname)]         ienumerable<guid> my_custom_field  {get; set;}         :         :         // few more fields                } 

create class called my_custom_type implement interface imy_custom_type, , add properties other interfaces class:

public class my_custom_type : imy_custom_type  { // imy_custom_type  properties // iglassbase  properties // imetadata properties // ibase_background_image properties }   

then try cast object :

var mycustomobj=sitecorecontext.getitem<my_custom_type>(itemid);  

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -