private void ApplyPaging(SimpleQuery query, List <ICommandBuilder> commandBuilders, ICommandBuilder mainCommandBuilder, SkipClause skipClause, TakeClause takeClause, bool hasWithClause, IQueryPager queryPager) { const int maxInt = 2147483646; IEnumerable <string> commandTexts; if (skipClause == null && !hasWithClause) { commandTexts = queryPager.ApplyLimit(mainCommandBuilder.Text, takeClause.Count); } else { var table = _adapter.GetSchema().FindTable(query.TableName); var keys = new string[0]; if (table.PrimaryKey != null && table.PrimaryKey.Length > 0) { keys = table.PrimaryKey.AsEnumerable() .Select(k => string.Format("{0}.{1}", table.QualifiedName, _adapter.GetSchema().QuoteObjectName(k))) .ToArray(); } int skip = skipClause == null ? 0 : skipClause.Count; int take = takeClause == null ? maxInt : takeClause.Count; commandTexts = queryPager.ApplyPaging(mainCommandBuilder.Text, keys, skip, take); } commandBuilders.AddRange( commandTexts.Select( commandText => new CommandBuilder(commandText, _adapter.GetSchema(), mainCommandBuilder.Parameters))); }
private void ApplyPaging(List <ICommandBuilder> commandBuilders, ICommandBuilder mainCommandBuilder, SkipClause skipClause, TakeClause takeClause, bool hasWithClause, IQueryPager queryPager) { const int maxInt = 2147483646; IEnumerable <string> commandTexts; if (skipClause == null && !hasWithClause) { commandTexts = queryPager.ApplyLimit(mainCommandBuilder.Text, takeClause.Count); } else { int skip = skipClause == null ? 0 : skipClause.Count; int take = takeClause == null ? maxInt : takeClause.Count; commandTexts = queryPager.ApplyPaging(mainCommandBuilder.Text, skip, take); } commandBuilders.AddRange( commandTexts.Select( commandText => new CommandBuilder(commandText, _adapter.GetSchema(), mainCommandBuilder.Parameters))); }
private void ApplyPaging(SimpleQuery query, List<ICommandBuilder> commandBuilders, ICommandBuilder mainCommandBuilder, SkipClause skipClause, TakeClause takeClause, bool hasWithClause, IQueryPager queryPager) { const int maxInt = 2147483646; IEnumerable<string> commandTexts; if (skipClause == null && !hasWithClause) { commandTexts = queryPager.ApplyLimit(mainCommandBuilder.Text, takeClause.Count); } else { var table = _adapter.GetSchema().FindTable(query.TableName); if (table.PrimaryKey == null || table.PrimaryKey.Length == 0) { throw new AdoAdapterException("Cannot apply paging to a table with no primary key."); } var keys = table.PrimaryKey.AsEnumerable() .Select(k => string.Format("{0}.{1}", table.QualifiedName, _adapter.GetSchema().QuoteObjectName(k))) .ToArray(); int skip = skipClause == null ? 0 : skipClause.Count; int take = takeClause == null ? maxInt : takeClause.Count; commandTexts = queryPager.ApplyPaging(mainCommandBuilder.Text, keys, skip, take); } commandBuilders.AddRange( commandTexts.Select( commandText => new CommandBuilder(commandText, _adapter.GetSchema(), mainCommandBuilder.Parameters))); }
private void ApplyPaging(List<ICommandBuilder> commandBuilders, ICommandBuilder mainCommandBuilder, SkipClause skipClause, TakeClause takeClause, IQueryPager queryPager) { const int maxInt = 2147483646; IEnumerable<string> commandTexts; if (skipClause == null) { commandTexts = queryPager.ApplyLimit(mainCommandBuilder.Text, takeClause.Count); } else { if (takeClause == null) takeClause = new TakeClause(maxInt); commandTexts = queryPager.ApplyPaging(mainCommandBuilder.Text, skipClause.Count, takeClause.Count); } commandBuilders.AddRange( commandTexts.Select( commandText => new CommandBuilder(commandText, _adapter.GetSchema(), mainCommandBuilder.Parameters))); }