Ejemplo n.º 1
0
        protected override IEnumerable <Entity> ExecuteInternal(IDictionary <string, DataSource> dataSources, IQueryExecutionOptions options, IDictionary <string, Type> parameterTypes, IDictionary <string, object> parameterValues)
        {
            var offset = SqlTypeConverter.ChangeType <int>(Offset.Compile(null, parameterTypes)(null, parameterValues, options));
            var fetch  = SqlTypeConverter.ChangeType <int>(Fetch.Compile(null, parameterTypes)(null, parameterValues, options));

            if (offset < 0)
            {
                throw new QueryExecutionException("The offset specified in a OFFSET clause may not be negative.");
            }

            if (fetch <= 0)
            {
                throw new QueryExecutionException("The number of rows provided for a FETCH clause must be greater then zero.");
            }


            return(Source.Execute(dataSources, options, parameterTypes, parameterValues)
                   .Skip(offset)
                   .Take(fetch));
        }