예제 #1
0
 private SqlCommand Get(Application.SearchModel model, SqlConnection connection) =>
 connection.CreateProcedureCommand(PROCEDURE)
 .AddPaginationParameters(model)
 .AddInParameter(PARAM_FILTERTEXT, model.FilterText)
 .AddInParameter(PARAM_FILTERBYPLATFORM, model.FilterByPlatform)
 .AddIntListParameter(PARAM_PLATFORMIDS, model.PlatformIds)
 .AddIntListParameter(PARAM_SKIPPEDIDS, model.SkippedIds);
예제 #2
0
        public async Task <Application.SearchResult> SearchAsync(Application.SearchModel model, CancellationToken cancellationToken = default)
        {
            var cacheKey = _cacheHelper.CreateKey <Application.SearchModel, Application.SearchResult>(model);

            if (TryGetFromCache(cacheKey, out Application.SearchResult result))
            {
                return(result);
            }

            using var process = GetProcess <ISearchApplication>();
            process.Model     = model;
            return(TrySaveToCache(cacheKey, await process.ExecuteAsync(cancellationToken), _configuration.CacheExpiration.Application.Search));
        }
예제 #3
0
        public async Task ExecuteAsync(Application.SearchModel model, Application.SearchResult result, SqlConnection connection, CancellationToken cancellationToken = default)
        {
            using var command = Get(model, connection);
            using var reader  = await command.ExecuteReaderAsync(cancellationToken);

            if (reader.HasRows)
            {
                while (await reader.ReadAsync(cancellationToken))
                {
                    result.Applications.Add(_readerConverter.Convert(reader));
                }
            }

            result.TotalCount = await ReadTotalCountAsync(reader, cancellationToken);
        }
예제 #4
0
 public Task <Application.SearchResult> SearchAsync(Application.SearchModel model, CancellationToken cancellationToken = default)
 {
     using var process = GetProcess <ISearchApplication>();
     process.Model     = model;
     return(process.ExecuteAsync(cancellationToken));
 }