/// <summary> /// 查询命令处理 /// </summary> /// <param name="command"></param> /// <returns></returns> public CacheServer.ResultData DeaCacheCommand(CacheServer.Command command) { if (command.CommandType == CacheServer.CommandType.查询) { var expression = LambdaQuery.CRLQueryExpression.FromJson(command.Data); return(QueryFromCache(expression)); } else { //更新缓存 var item = (TModel)CoreHelper.SerializeHelper.SerializerFromJSON(command.Data, typeof(TModel), Encoding.UTF8); var updateModel = MemoryDataCache.CacheService.GetCacheTypeKey(typeof(TModel)); foreach (var key in updateModel) { MemoryDataCache.CacheService.UpdateCacheItem(key, item, null); } return(new CacheServer.ResultData()); } }
/// <summary> /// 查询命令处理 /// </summary> /// <param name="command"></param> /// <returns></returns> public CacheServer.ResultData DeaCacheCommand(CacheServer.Command command) { if (command.CommandType == CacheServer.CommandType.查询) { var expression = LambdaQuery.CRLExpression.CRLQueryExpression.FromJson(command.Data); return(QueryFromCache(expression)); } else { //更新缓存 var item = (T)SerializeHelper.DeserializeFromJson <T>(command.Data); var db = DBExtend as AbsDBExtend; var updateModel = MemoryDataCache.CacheService.GetCacheTypeKey(typeof(T), db.__DbHelper.DatabaseName); foreach (var key in updateModel) { MemoryDataCache.CacheService.UpdateCacheItem(key, item, null); } return(new CacheServer.ResultData()); } }
/// <summary> /// 直接按查询数据 /// </summary> /// <param name="command"></param> /// <returns></returns> public CacheServer.ResultData DeaDataQueryCommand(CacheServer.Command command) { if (command.CommandType == CacheServer.CommandType.查询) { var expression = LambdaQuery.CRLQueryExpression.FromJson(command.Data); var _CRLExpression = new CRL.LambdaQuery.CRLExpressionVisitor <TModel>().CreateLambda(expression.Expression); var query = GetLambdaQuery(); query.Where(_CRLExpression); query.Page(expression.PageSize, expression.PageIndex); var data = query.ToList(); int total = query.RowCount; return(new CacheServer.ResultData() { Total = total, JsonData = CoreHelper.StringHelper.SerializerToJson(data) }); } else { //更新缓存 //var item = (TModel)CoreHelper.SerializeHelper.SerializerFromJSON(command.Data, typeof(TModel), Encoding.UTF8); //UpdateById(item); return(new CacheServer.ResultData()); } }