public override void BuildExportList()
        {
            SetupExpressionRunner(ReportModel.ReportSettings, null);
            base.BuildExportList();
            BuildDetail();
            BuildReportFooter();
            AddPage(CurrentPage);
            UpdatePageInfo();
//			RunDebugVisitor();
            ExpressionRunner.Run();
        }
Beispiel #2
0
        /// <summary>
        /// Gets a list of entities of the given type from the database.
        /// </summary>
        public TOutput?Aggregate <TProperty, TOutput>(AggregateFunction function, Expression <Func <TEntity, TProperty> > property, Expression <Func <TEntity, bool> > criteria) where TOutput : struct
        {
            var runner = ExpressionRunner <TEntity> .CreateRunner(criteria);

            if (runner.DynamicCriteria == null)
            {
                var conditions = runner.Conditions.OfType <ICriterion>().ToArray();
                return(Aggregate <TProperty, TOutput>(function, property, conditions));
            }
            else
            {
                throw new InvalidOperationException("Database Aggregate functions can be used only if the criteria can be evaluated in the database. If your criteria has to execute in CLR, then use Database.GetList() and run the LINQ aggregation on it.");
            }
        }
        public override void BuildExportList()
        {
            CreateDataSource();
            SetupExpressionRunner(ReportModel.ReportSettings, DataSource);
            base.BuildExportList();
            BuildDetail();
            BuildReportFooter();
            AddPage(CurrentPage);
            UpdatePageInfo();
            ExpressionRunner.Run();
            var formatVisitor = new FormatVisitor();

            formatVisitor.Run(Pages);
            var dv = new DebugVisitor();

            dv.Run(Pages);
        }
        /// <summary>
        /// Gets a list of entities of the given type from the database.
        /// </summary>
        public static int Count <T>(Expression <Func <T, bool> > criteria, params QueryOption[] options) where T : IEntity
        {
            var runner = ExpressionRunner <T> .CreateRunner(criteria);

            if (runner.DynamicCriteria == null)
            {
                var conditions = runner.Conditions.OfType <ICriterion>().ToList();

                if (SoftDeleteAttribute.RequiresSoftdeleteQuery <T>())
                {
                    conditions.Add(new Criterion("IsMarkedSoftDeleted", false));
                }

                return(GetProvider(typeof(T)).Count(typeof(T), conditions, options ?? new QueryOption[0]));
            }
            else
            {
                return(GetList <T>(criteria, options).Count());
            }
        }
        /// <summary>
        /// Gets a list of entities of the given type from the database.
        /// </summary>
        public static IEnumerable <T> GetList <T>(Expression <Func <T, bool> > criteria, params QueryOption[] options) where T : IEntity
        {
            options = options ?? new QueryOption[0];

            var runner = ExpressionRunner <T> .CreateRunner(criteria);

            if (runner.DynamicCriteria == null)
            {
                return(GetList <T>(runner.Conditions.Cast <ICriterion>(), options));
            }
            else
            {
                var result = GetList <T>(runner.Conditions);
                result = result.Where(r => runner.DynamicCriteria(r)).ToArray();

                var resultsToFetch = options.GetResultsToFetch();
                if (resultsToFetch.HasValue && resultsToFetch.HasValue && result.Count() > resultsToFetch)
                {
                    result = result.Take(resultsToFetch.Value).ToArray();
                }

                return(result);
            }
        }
 protected void SetupExpressionRunner(IReportSettings reportsettings, CollectionDataSource dataSource)
 {
     ExpressionRunner = new ExpressionRunner(Pages, reportsettings, dataSource);
 }