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);
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)); }
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); }
public Task <Module.SearchResult> SearchAsync(Module.SearchModel model, CancellationToken cancellationToken = default) { using var process = GetProcess <ISearchModule>(); process.Model = model; return(process.ExecuteAsync(cancellationToken)); }