/// <summary> /// Найти контейнеры по фильтру /// </summary> /// <param name="specification">specification</param> /// <param name="sortField">sortField</param> /// <param name="sortType">sortType</param> /// <param name="offset">offset</param> /// <param name="limit">limit</param> /// <returns>Коллекция контейнеров</returns> public async Task <List <RealContainer> > GetListAsync(ASpecification specification, string sortField, string sortType, int offset, int limit) { using (var sqlConnect = Connections.GetLM()) { var sql = $@"SELECT {_bodyModel} FROM [BankValues].[Cassetes] cass {_joinModel} WHERE 1=1 {specification.ToSql()} ORDER BY {sortField} {sortType} OFFSET {offset} ROWS FETCH NEXT {limit} ROWS ONLY;"; var args = new DynamicParameters(new { }); foreach (var spec in specification.ToSqlParameters()) { args.Add(spec.ParameterName, spec.Value); } var result = await sqlConnect.QueryAsync <RealContainer>(sql, args); var list = result.ToList(); return(list); } }
/// <summary> /// Получить кол-во контейнеров по КЦ, типу, QR коду /// </summary> /// <param name="specification">specification</param> /// <returns>Кол-во контейнеров</returns> public async Task <int> GetCountAsync(ASpecification specification) { using (var sqlConnect = Connections.GetLM()) { var sql = $@"SELECT COUNT(cass.[idCassete]) AS RealContainersCount FROM [BankValues].[Cassetes] cass WHERE 1=1 {specification.ToSql()}"; var args = new DynamicParameters(new { }); foreach (var spec in specification.ToSqlParameters()) { args.Add(spec.ParameterName, spec.Value); } var result = await sqlConnect.ExecuteScalarAsync <int>(sql, args); return(result); } }