0

I'm having a problem storing an object containing a dictionary using ServiceStack.Redis. The object that I'm trying to store is defined as below:

public class Feed
{
    public Guid ID { get; set; }
    public String Title { get; set; }
    public String Description { get; set; }
    public Object Details { get; set; }
    public Int32 SortOrder { get; set; }
    public Image Picture { get; set; }
    public String FeedType { get; set; }
    public long ArticleCount { get; set; }
    public String ParentTheme { get; set; }
    public Guid ParentThemeID { get; set; }
    public Boolean IsFavourite { get; set; }
    public Boolean? Hidden { get; set; }
    public Dictionary<String, String> ExtendedProperties { get; set; }
}

Although most of the object gets serialised correctly, but the Dictionary property (ExtendedProperties) does not get serialised.

I have tried setting JsConfig.IncludePublicFields = true but it doesn't seem to make any difference.

What is most confusing me is that it would seem that the dictionary is serialised some of the time (mostly when I'm stepping through the code in the debugger it seems) but not reproducibly.

Does anyone have any suggestions as to how I can get the dictionary to be successfully serialised (beyond using Newtonsoft.Json to serialize the object to a staring, and then storing that directing in Redis)

Many Thanks,

Richard.

Richard Comish
  • 197
  • 2
  • 20
  • Check out this [question](http://stackoverflow.com/questions/495647/serialize-class-containing-dictionary-member) – Gridly Jun 09 '14 at 22:17
  • That looks to be XML Serialization with the Microsoft XMLSerializer class. This is with ServiceStack.Redis/ServiceStack.Text serialising to Json. – Richard Comish Jun 10 '14 at 10:16
  • 1
    One possible option left out can be most likely to convert your Dictionary object to json and then serialize it and save it (something you prefer not to but is an available option) – Chhavi Gangwal Jun 10 '14 at 12:25
  • Thanks @ChhaviGangwal - I think realistically that's what I'll have to do in the short term since I need to get this working ASAP. – Richard Comish Jun 10 '14 at 13:06

0 Answers0