【问题标题】:Cache List<T> returning nulls缓存列表<T> 返回空值
【发布时间】:2013-12-11 22:44:36
【问题描述】:

如果我缓存 List&lt;string&gt; 并执行 Get,我将返回四个项目及其值(如预期的那样)。如果我缓存 List&lt;PortedNumberCollection&gt; 并执行 Get- 我得到正确数量的项目,但所有值(MSISDN、RoutingLabel、RouteAction)都是空的,为什么?

[DataContract]
public class PortedNumberCollection
{
    [DataMember]        
    public Int64 PortedID;

    [DataMember]        
    public string MSISDN;

    [DataMember]        
    public string RoutingLabel;

    [DataMember]
    public string RouteAction;
}

string host = "localhost";

RedisClient redi = new RedisClient(host);

//List<string> PorCol = new List<string> {
//    "Hi there",
//    "Hello world",
//    "Many name is",
//    "Uh, my name is"
//};

List<PortedNumberCollection> PorCol = MobileDAL.ReadPortedNumberCollection();
redi.Set("PorColCache", PorCol);

//List<string> msgs = redi.Get<List<string>>("PorColCache");
List<PortedNumberCollection> msgs = redi.Get<List<PortedNumberCollection>>("PorColCache");

【问题讨论】:

  • 将此作为答案,您将获得积分。你的建议奏效了。

标签: c# redis .net-4.5


【解决方案1】:

您可以尝试添加 {get; set;} 在字段之后?像公共字符串 RouteAction {get;设置;}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-12
    • 2016-04-01
    • 1970-01-01
    • 2021-01-17
    相关资源
    最近更新 更多