servicestack.redis,C#,Asp.net,servicestack.redis" /> servicestack.redis,C#,Asp.net,servicestack.redis" />

C# RedisClientManager,类型为'的未处理异常;System.StackOverflowException';发生在mscorlib.dll中

C# RedisClientManager,类型为'的未处理异常;System.StackOverflowException';发生在mscorlib.dll中,c#,asp.net,servicestack.redis,C#,Asp.net,servicestack.redis,我正在使用RedisClientManager,并且在尝试设置对象时,在mscorlib.dll中发生“System.StackOverflowException”类型的未处理异常 client.Set<ApplicationUser>(user.Id, user); client.Set(user.Id,user); 和用户: public class ApplicationUser : IdentityUser { public string Name

我正在使用RedisClientManager,并且在尝试设置对象时,在mscorlib.dll中发生“System.StackOverflowException”类型的未处理异常

client.Set<ApplicationUser>(user.Id, user);
client.Set(user.Id,user);
和用户:

public class ApplicationUser : IdentityUser
{        
    public string Name { get; set; }
    public string Surname { get; set; }
    public DateTime? BirthDay { get; set; }
    public int BirthPlace { get; set; }
    public int TeamId { get; set; }
    public int AvatarId { get; set; }
    public string Address { get; set; }
    public DateTime RegisterationDate { get; set; }
    public DateTime CodeSendDate { get; set; }
    public string ActivationCode { get; set; }
    public string PasswordResetToken { get; set; }
    public string FacebookAvatar { get; set; }
    public string FacebookId { get; set; }
    public bool UseFacebookAvatar { get; set; }
    public string IpAddress { get; set; }

    public virtual Avatar Avatar { get; set; }

    public ApplicationUser()
    {
        this.Coupons = new HashSet<Coupon>();
    }

    [JsonIgnore]
    public virtual ICollection<Coupon> Coupons { get; set; }
}
公共类应用程序用户:IdentityUser
{        
公共字符串名称{get;set;}
公共字符串姓氏{get;set;}
公共日期时间?生日{get;set;}
公共int出生地{get;set;}
public int TeamId{get;set;}
公共属性{get;set;}
公共字符串地址{get;set;}
公共日期时间注册表日期{get;set;}
公共日期时间CodeSendDate{get;set;}
公共字符串激活代码{get;set;}
公共字符串PasswordResetToken{get;set;}
公共字符串FacebookAvatar{get;set;}
公共字符串FacebookId{get;set;}
公共bool UseFacebookAvatar{get;set;}
公共字符串IpAddress{get;set;}
公共虚拟化身{get;set;}
公共应用程序用户()
{
this.tuples=newhashset();
}
[JsonIgnore]
公共虚拟ICollection优惠券{get;set;}
}
序列化ApplicationUser时出错,我尝试在ICollection上添加
[JsonIgnore]
,因为嵌套循环,(优惠券包含用户)
我找不到有什么问题吗

我找到了适合我的解决方案。 ApplicationUser对象具有优惠券,优惠券具有ApplicationUser(多对多) 因此,序列化将进入无限循环

我添加
[IgnoreDataMember]

public class ApplicationUser : IdentityUser
{        
    public string Name { get; set; }
    public string Surname { get; set; }
    public DateTime? BirthDay { get; set; }
    public int BirthPlace { get; set; }
    public int TeamId { get; set; }
    public int AvatarId { get; set; }
    public string Address { get; set; }        
    public DateTime RegisterationDate { get; set; }        
    public DateTime CodeSendDate { get; set; }
    public string ActivationCode { get; set; }
    public string PasswordResetToken { get; set; }
    public string FacebookAvatar { get; set; }
    public string FacebookId { get; set; }
    public bool UseFacebookAvatar { get; set; }
    public string IpAddress { get; set; }        

    public virtual Avatar Avatar { get; set; }


    public ApplicationUser()
    {
        this.Coupons = new HashSet<Coupon>();
    }

    [IgnoreDataMember]
    public virtual ICollection<Coupon> Coupons { get; set; }
}
公共类应用程序用户:IdentityUser
{        
公共字符串名称{get;set;}
公共字符串姓氏{get;set;}
公共日期时间?生日{get;set;}
公共int出生地{get;set;}
public int TeamId{get;set;}
公共属性{get;set;}
公共字符串地址{get;set;}
公共日期时间注册表日期{get;set;}
公共日期时间CodeSendDate{get;set;}
公共字符串激活代码{get;set;}
公共字符串PasswordResetToken{get;set;}
公共字符串FacebookAvatar{get;set;}
公共字符串FacebookId{get;set;}
公共bool UseFacebookAvatar{get;set;}
公共字符串IpAddress{get;set;}
公共虚拟化身{get;set;}
公共应用程序用户()
{
this.tuples=newhashset();
}
[IgnoreDataMember]
公共虚拟ICollection优惠券{get;set;}
}
现在我可以忽略优惠券属性,以便Servis.Stack redisClientManager可以序列化该对象