/// <summary> /// 指定検索条件下でのインデックスを調べる /// </summary> /// <param name="criteria"></param> /// <param name="target"></param> /// <returns></returns> private async Task <long> FindIndexMainAsync (IDbConnection connection, ISearchCriteria criteria, IDatabaseExpression filterSql, Record target) { var sql = SortSetting.GetReferenceSelectorSql(criteria.GetSort()); var reference = await this.Records .GetDynamicParametersAsync(connection, sql, target) .ConfigureAwait(false); if (reference == null) { return(-1); } var filter = DatabaseExpression.And(filterSql, SortSetting.GetOrderFilterSql(criteria.GetSort())); return((await this.Records.CountAsync(connection, filter, reference).ConfigureAwait(false)) - 1); }
public async Task <object> GetSortReferenceAsync(ISearchCriteria criteria, Record target) { using (var connection = await this.Records.Parent.ConnectAsync().ConfigureAwait(false)) { var sql = SortSetting.GetReferenceSelectorSql(criteria.GetSort()); return(await this.Records .GetDynamicParametersAsync(connection, sql, target) .ConfigureAwait(false)); } }
public async Task <string[]> GetRegionIdsMainAsync (IDbConnection connection, ISearchCriteria criteria, long index1, long index2, IDatabaseExpression filter) { if ((index1 < 0 && index2 < 0) || (index1 < 0 || index1 == index2) || (index2 < 0)) { return(null); } var startIndex = index1; var endIndex = index2; //var startRecord = record1; //var endRecord = record2; if (index2 < index1) { startIndex = index2; endIndex = index1; //startRecord = record2; //endRecord = record1; } if (index2 - index1 == 1) { return(null); } var sort = SortSetting.GetFullSql(criteria.GetSort()); return(await this.Records .AsQueryable(connection) .Where(filter) .OrderBy(sort.Append(FileProperty.Id.ToSort(false)).ToArray()) .Select <string>(nameof(Record.Id)) .Skip(startIndex + 1) .Take(endIndex - startIndex - 1) .ToArrayAsync() .ConfigureAwait(false)); }