I'm using Stackexchange.Redis for Redis cache on Azure with Glass mapper and Sitecore 8.1 - For Glass mapper implementation I'm using interfaces as models and maps configuration to get the data.
Now the issue is that for Redis provider to work we should pass the object as serializable which can only happen in classes but I'm using interfaces as model with glass mapper. If I use classes as model and serialize it my redis implementation works just fine but then I'll be limited to have multiple inheritence in my template.
Can anyone please suggest how to use Glass Mapper interfaces to be pushed into Redis cache or any work around for this?
Below is the error I'm getting while serializing the Interface: Type
'System.Linq.Enumerable+WhereSelectEnumerableIterator`2[[Sitecore.Data.Templates.Template, Sitecore.Kernel, Version=8.1.0.0, Culture=neutral, PublicKeyToken=null],[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' in Assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteArrayMember(WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, Object data) at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteArray(WriteObjectInfo objectInfo, NameInfo memberNameInfo, WriteObjectInfo memberObjectInfo) at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph) at
public class SampleItemMap : SitecoreGlassMap<ISampleItem>
{
public override void Configure()
{
Map(x =>
{
ImportMap<IGlassBase>();
x.TemplateId("{21AB47FD-F264-48B4-ABF4-1FF5B10FB4A4}");
x.Cachable();
x.AutoMap();
});
}
}
And the Interface for Handling the Default SampleItem template is as below:
public interface ISampleItem : IGlassBase
{
string Title { get; set; }
string Text { get; set; }
}