• ABP缓存写法


    异步

                var  cache= await _cacheManager.GetCache("OrganCache").GetAsync<string, List<OrganListDto>>("OrganCache"+ "_"+input.Level, async f => {
    
                    var q = from r in _repository.GetAll().Where(x => x.Level == input.Level)
    
                          //.WhereIf(input.FatherId > 0, x => x.FatherId == input.FatherId)
                           select r;
    
                    var re= await  q.AsNoTracking().ToListAsync();
                    return re.MapTo<List<OrganListDto>>();
    
                });

    同步

                    BroadcastDeviceCtrl getCtrl = _cacheManager.GetCache("BroadcastCache").Get<string, BroadcastDevice>(key, f =>
                    {
    
                        RecordBroadcast broadcast = _recordBroadcastRepository.GetAll().FirstOrDefault(x => x.Id == Guid.Parse(key));
    
                        return new BroadcastDevice(Guid.Parse(key),
                            broadcast.Manufacturer,
                            _recordIpRepository.GetAll().FirstOrDefault(x => x.BroadcastId == broadcast.Id && x.IsInnerIp)?.IpAddress,
                            broadcast.MacAddr,
                            broadcast.CtrPortJson);
    
                    }).GetCtrl;
  • 相关阅读:
    构建之法阅读笔记02
    学习进度条
    构建之法阅读笔记01
    c++ 与C的区别
    c++ 菜单动态效果
    c++ 方框中绘制菜单代码
    c++ 绘制方框
    c++ 条件编译
    c++ 预处理和多重替换
    c++ 文件共享打开
  • 原文地址:https://www.cnblogs.com/wangyinlon/p/12518137.html
Copyright © 2020-2023  润新知