Example #1
0
        protected override IEnumerable <Entity> ExecuteInternal(IDictionary <string, DataSource> dataSources, IQueryExecutionOptions options, IDictionary <string, Type> parameterTypes, IDictionary <string, object> parameterValues)
        {
            var topCount = Top.Compile(null, parameterTypes)(null, parameterValues, options);

            if (Percent)
            {
                int count;

                if (Source is TableSpoolNode spool && spool.SpoolType == SpoolType.Eager)
                {
                    count = spool.GetCount(dataSources, options, parameterTypes, parameterValues);
                }
                else
                {
                    count = Source.Execute(dataSources, options, parameterTypes, parameterValues).Count();
                }

                topCount = (int)(count * SqlTypeConverter.ChangeType <float>(topCount) / 100);
            }