/// <summary> /// Load at most N async values. /// </summary> /// <param name="n">Number of values from the current position to be loaded</param> /// <param name="back">offset, it can be positive or negative</param> /// <returns></returns> public async Task <IEnumerable <CompanyDto> > LoadValueAtMostAsync(int n, int back = 0) { IEnumerable <CompanyDto> companyDto = new List <CompanyDto>(); IQueryStore store = _queryStoreFactory.GetQueryStore(); using (IDbConnection connection = _sqlExecutor.OpenNewDbConnection()) { store.AddParamRange(QueryType.QueryPagedCompany, _currentPos, n); _currentPos += n + back; var query = store.BuildQuery(); var value = await connection.QueryAsync <SUBLICEN>(query); } return(companyDto); }
public async Task <IEnumerable <OfficeDtos> > LoadValueAtMostAsync(int n, int back = 0) { IEnumerable <OfficeDtos> officeDtos = new List <OfficeDtos>(); IQueryStore store = _queryStoreFactory.GetQueryStore(); using (IDbConnection connection = _executor.OpenNewDbConnection()) { store.AddParamRange(QueryType.QueryPagedCompany, _currentPos, n); _currentPos += n + back; var query = store.BuildQuery(); var value = await connection.QueryAsync <OFICINAS>(query); officeDtos = _mapper.Map <IEnumerable <OFICINAS>, IEnumerable <OfficeDtos> >(value); } return(officeDtos); }
/// <summary> /// It load at most n entities. It retains the state in order to support paging. /// </summary> /// <param name="n">Number of state.</param> /// <returns>It returns a list of n client data transfer objects</returns> public async Task <IEnumerable <ClientDto> > LoadValueAtMostAsync(int n, int back) { IEnumerable <ClientDto> dtoCollection = new List <ClientDto>(); IQueryStore store = _queryStoreFactory.GetQueryStore(); store.AddParamRange(QueryType.QueryPagedClient, _currentQueryPos, n); var query = store.BuildQuery(); _currentQueryPos = _currentQueryPos + n - back; using (IDbConnection conn = _sqlExecutor.OpenNewDbConnection()) { var currentPoco = await conn.QueryAsync <ClientPoco>(query); dtoCollection = _mapper.Map <IEnumerable <ClientPoco>, IEnumerable <ClientDto> >(currentPoco); } return(dtoCollection); }