public JsonResult Get() { this._dbContext = _dbContext.ToRead();//读写分离 var list = _dbContext.CmNumberInfo.ToList(); return(new JsonResult(list)); //return new string[] { "value1", "value2" }; }
public JsonResult Get() { this._dbContext = _dbContext.ToRead();//读写分离 List <CmNumberInfo> cmNumberInfo = new List <CmNumberInfo> (); if (RedisHelper.Get("cmnumber") != null) { cmNumberInfo = System.Text.Json.JsonSerializer.Deserialize <List <CmNumberInfo> >(RedisHelper.Get("cmnumber")); //RedisHelper.Del("cmnumber"); } else { cmNumberInfo = _dbContext.CmNumberInfo.ToList(); RedisHelper.Set("cmnumber", System.Text.Json.JsonSerializer.SerializeToUtf8Bytes(cmNumberInfo)); } return(new JsonResult(cmNumberInfo)); //return new string[] { "value1", "value2" }; }
public IEnumerable <CmNumberInfo> GetNumberList() { _dbContext = _dbContext.ToRead(); return(_dbContext.CmNumberInfo.Take(2).ToList()); }