我在使用 ServiceStack.Redis 存储包含字典的对象时遇到问题。我试图存储的对象定义如下:
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; }
}
尽管大多数对象都被正确序列化,但 Dictionary 属性 (ExtendedProperties) 没有被序列化。
我试过设置 JsConfig.IncludePublicFields = true 但它似乎没有任何区别。
最让我困惑的是,字典似乎在某些时候是序列化的(主要是当我在调试器中单步执行代码时),但不是可重复的。
有没有人对我如何使字典成功序列化有任何建议(除了使用 Newtonsoft.Json 将对象序列化为凝视,然后将该指示存储在 Redis 中)
非常感谢,
理查德。