缓存列表<t>返回空值</t>

时间:2013-11-26 16:47:54

标签: c# redis .net-4.5

如果我缓存List<string>并执行Get,我会将四个项目返回其值(如预期的那样)。如果我缓存List<PortedNumberCollection>并执行Get-I得到正确数量的项目,但所有值(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");

1 个答案:

答案 0 :(得分:1)

你能尝试添加{get;在字段之后设置;}像公共字符串RouteAction {get;设置;}