Ejemplo n.º 1
0
        public virtual void Where()
        {
            AstoriaTestLog.WriteLineIgnore("Calling Where");

            //Sub model - projections
            PredicateModel model  = new PredicateModel(this.Workspace, this.ResContainer, this.property, this.ParentRelKey, this.ResType);
            ModelEngine    engine = new ModelEngine(this.Engine, model);

            engine.Run();

            ExpNode e = model.Result;

            this.ParentRelKey = e as KeyExpression;
            if (null == _parentKey)
            {
                /* no keys for resource type*/
                this.Reload();
                return;
            }

            int i = this.Engine.Options.Random.Next(0, 10);

            if (i % 7 == 0)
            {
                e       = ((KeyExpression)e).Predicate;
                bFilter = true;
            }

            if (e != null)
            {
                if (_query is ScanExpression)
                {
                    _query = ((ScanExpression)_query).Where(e) as PredicateExpression;
                }
                else if (_query is NavigationExpression)
                {
                    _query = ((NavigationExpression)_query).Where(e) as PredicateExpression;
                }

                bWhere  = true;
                IsKey   = true;
                _action = LastAction.Where;
                AstoriaTestLog.WriteLineIgnore(".Where()");
            }
        }
Ejemplo n.º 2
0
        public void Sort(bool bAsc)
        {
            //Sub model - sort
            SortModel   model  = new SortModel(this._workspace, _fromContainer.BaseType);
            ModelEngine engine = new ModelEngine(this.Engine, model);

            engine.Run();

            PropertyExpression[] ordervalues = model.SortResult;

            if (_query is TopExpression)
            {
                _query = ((TopExpression)_query).Sort(ordervalues, bAsc) as OrderByExpression;
            }
            else if (_query is SkipExpression)
            {
                _query = ((SkipExpression)_query).Sort(ordervalues, bAsc) as OrderByExpression;
            }
            else if (_query is CountExpression)
            {
                _query = ((CountExpression)_query).Sort(ordervalues, bAsc) as OrderByExpression;
            }
            else if (_query is ExpandExpression)
            {
                _query = ((ExpandExpression)_query).Sort(ordervalues, bAsc) as OrderByExpression;
            }
            else if (_query is NavigationExpression)
            {
                _query = ((NavigationExpression)_query).Sort(ordervalues, bAsc) as OrderByExpression;
            }
            else if (_query is PredicateExpression)
            {
                _query = ((PredicateExpression)_query).Sort(ordervalues, bAsc) as OrderByExpression;
            }
            else if (_query is ScanExpression)
            {
                _query = ((ScanExpression)_query).Sort(ordervalues, bAsc) as OrderByExpression;
            }

            bSort     = true;
            _action   = LastAction.OrderBy;
            bIsOption = true;
            AstoriaTestLog.WriteLineIgnore(".OrderBy(" + ordervalues.ToString() + ")");
        }
Ejemplo n.º 3
0
        public virtual void From()
        {
            if (RunningUnderScenarioModel)
            {
                _query = Query.From(Exp.Variable(ResContainer));
                _pType = ResContainer.BaseType.ClientClrType;
                AstoriaTestLog.WriteLineIgnore("Query.From(" + ResContainer.Name + ")");
            }
            else
            {
                ScanModel   model  = new ScanModel(_workspace);
                ModelEngine engine = new ModelEngine(this.Engine, model);
                engine.Run();

                this.ResContainer = model.ResultContainer;
                _query            = Query.From(Exp.Variable(model.ResultContainer));
                _pType            = model.ResultContainer.BaseType.ClientClrType;
                AstoriaTestLog.WriteLineIgnore("Query.From(" + model.ResultContainer.Name + ")");
            }


            _action = LastAction.From;
            IsCount = false;
        }