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

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

            using var process = GetProcess <ISearchModule>();
            process.Model     = model;
            return(TrySaveToCache(cacheKey, await process.ExecuteAsync(cancellationToken), _configuration.CacheExpiration.Module.Search));
        }
예제 #3
0
        public async Task ExecuteAsync(Module.SearchModel model, Module.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.Modules.Add(_readerConverter.Convert(reader));
                }
            }

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