主要报错:
Stack overflow.
Repeat 13770 times:
--------------------------------
at Simple.Repository.DataFilter..ctor()
--------------------------------
at Simple.Repository.SimpleDbContext..ctor(Microsoft.EntityFrameworkCore.DbContextOptions`1<Simple.Repository.SimpleDbContext>, Simple.Common.Services.ICurrentUserService)
相关代码:
// SimpleDbContext
public class SimpleDbContext : DbContext
{
public virtual DataFilter DataFilter { get; set; } = new DataFilter();
}
public class DataFilter
{
private static DataFilter _default;
public bool IgnoreSoftDelete { get; set; }
static DataFilter()
{
// 这种方式赋值,在构造函数中无法获取到值
//_default = new DataFilter()
//{
// IgnoreSoftDelete = false
//};
}
public DataFilter()
{
// 这种写法直接 Stack Overflow 了
if(_default == null)
{
_default = new DataFilter()
{
IgnoreSoftDelete = false
};
}
IgnoreSoftDelete = _default.IgnoreSoftDelete;
}
}
遇到一个莫名其妙的问题,先发上来,看看有没大佬能解疑一下。
个人同步去找答案,找到再回来跟帖_