Skip to content

Async Await

ansonzhang edited this page Jun 6, 2019 · 1 revision

整个项目采用异步的方法:

比如异步仓储

  public async Task<TEntity> QueryById(object objId, bool blnUseCache = false)
  {
      //return await Task.Run(() => _db.Queryable<TEntity>().WithCacheIF(blnUseCache).InSingle(objId));
      return await _db.Queryable<TEntity>().WithCacheIF(blnUseCache).In(objId).SingleAsync();
  }

比如异步服务

  public async Task<TEntity> QueryById(object objId)
  {
      return await BaseDal.QueryById(objId);
  }


异步接口

  public async Task<MessageModel<PageModel<Module>>> Get(int page = 1, string key = "")
  {
      if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
      {
          key = "";
      }
      int intPageSize = 50;

      var data = await _moduleServices.QueryPage(a => a.IsDeleted != true && (a.Name != null && a.Name.Contains(key)), page, intPageSize, " Id desc ");

      return new MessageModel<PageModel<Module>>()
      {
          msg = "获取成功",
          success = data.dataCount >= 0,
          response = data
      };

  }


入门指南

前端项目

交流与反馈

  • FAQ page is a good place to see whether your question is already asked.
  • Ask a question in cnblogs if you need help.
  • Submit an issue if you found a bug or have a feature request.
  • Open a pull request when you prepared to contribute. Before that, it is encouraged to open an issue to discuss.

更新日志

Clone this wiki locally