Exemplo n.º 1
0
        internal void Refresh(QueryOrderBy orderBy)
        {
            if (orderBy == null)
            {
                return;
            }

            ucField.SelectedValue = orderBy.FieldName;
            ucOrderDirection.SelectEnum(orderBy.Direction);
        }
Exemplo n.º 2
0
        public override Node VisitQueryOrderBy(QueryOrderBy orderby)
        {
            orderby.Source = this.VisitExpression(orderby.Source);
            Composer save    = this.contextComposer;
            Composer c       = this.contextComposer = this.GetComposer(orderby.Source);
            bool     savehcr = this.hasContextReference;

            this.hasContextReference = false;
            this.VisitExpressionList(orderby.OrderList);
            this.hasContextReference = savehcr;
            this.contextComposer     = save;
            return(this.Compose(orderby, c));
        }
Exemplo n.º 3
0
        private void AddFilter(QueryOrderBy orderBy = null)
        {
            var filter = Controller.Add();

            filter.Refresh(orderBy);

            filter.SetBinding(OrderByFilterControl.DisplayColumnsByTitleProperty, new Binding
            {
                Source = this,
                Path   = new PropertyPath(nameof(DisplayColumnsByTitle)),
                Mode   = BindingMode.TwoWay
            });
        }
Exemplo n.º 4
0
        public void QueryOrderByTest()
        {
            // prepare
            var query = new QueryOrderBy(new Dictionary <string, OrderType>
            {
                { "phenomenonTime", OrderType.Descending },
                { "result", OrderType.Ascending }
            });

            // assert
            Assert.AreEqual(2, query.Value.Count);
            Assert.AreEqual("orderby", query.GetQueryParam());
            Assert.AreEqual("phenomenonTime desc,result asc", query.GetQueryValueString());
        }
Exemplo n.º 5
0
        private void Initialize(string typeOf, params object[] primaryOf)
        {
            TypeOf            = typeOf;
            CacheOf           = new QueryCacheOf();
            Parameters        = new QueryParameters();
            OrderBy           = new QueryOrderBy();
            HasPrimaryOf      = primaryOf.Length > 0;
            OrderBy.Direction = OrderByDirection.Asc;

            foreach (var primaryOfValue in primaryOf)
            {
                AddParameter(new QueryParameter
                {
                    Type  = ParameterType.PrimaryOf,
                    Field = DocumentDefaults.DocumentMetaPrimaryOfProperty,
                    Value = primaryOfValue
                });
            }
        }
Exemplo n.º 6
0
 public override Node VisitQueryOrderBy(QueryOrderBy orderby){
   if (orderby == null) return null;
   orderby.Source = this.VisitExpression(orderby.Source);
   if (orderby.Source == null || orderby.Source.Type == null) return orderby;
   TypeNode sourceElementType = this.typeSystem.GetStreamElementType(orderby.Source, this.TypeViewer);
   orderby.Context = this.contextScope = new ContextScope(this.contextScope, sourceElementType);
   orderby.OrderList = this.VisitExpressionList(orderby.OrderList);
   this.contextScope = this.contextScope.Previous;
   orderby.Type = this.GetResultType(orderby.Source, null, Cardinality.One);
   return orderby;
 }    
Exemplo n.º 7
0
 public virtual void VisitQueryOrderBy(QueryOrderBy orderby){
   if (orderby == null) return;
   this.VisitExpression(orderby.Source);
   this.VisitExpressionList(orderby.OrderList);
 }
Exemplo n.º 8
0
 public override Node VisitQueryOrderBy(QueryOrderBy orderby){
   if (orderby == null) return null;
   return base.VisitQueryOrderBy((QueryOrderBy)orderby.Clone());
 }
Exemplo n.º 9
0
 public virtual Node VisitQueryOrderBy(QueryOrderBy orderby1, QueryOrderBy orderby2){
   if (orderby1 == null) return null;
   if (orderby2 == null){
     orderby1.Source = this.VisitExpression(orderby1.Source, null);
     orderby1.OrderList = this.VisitExpressionList(orderby1.OrderList, null);
   }else{
     orderby1.Source = this.VisitExpression(orderby1.Source, orderby2.Source);
     orderby1.OrderList = this.VisitExpressionList(orderby1.OrderList, orderby2.OrderList);
   }
   return orderby1;
 }
Exemplo n.º 10
0
    public virtual Differences VisitQueryOrderBy(QueryOrderBy orderby1, QueryOrderBy orderby2){
      Differences differences = new Differences(orderby1, orderby2);
      if (orderby1 == null || orderby2 == null){
        if (orderby1 != orderby2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      QueryOrderBy changes = (QueryOrderBy)orderby2.Clone();
      QueryOrderBy deletions = (QueryOrderBy)orderby2.Clone();
      QueryOrderBy insertions = (QueryOrderBy)orderby2.Clone();

      //      orderby1.Context;
      //      orderby1.OrderList;
      //      orderby1.Source;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
Exemplo n.º 11
0
 public static IOrder <TEntity> ApplyOrderBy <TEntity>(this IOrder <TEntity> order, Expression <Func <TEntity, object> > query, QueryOrderBy sort) where TEntity : BaseEntity
 {
     order.Setstock(query, sort);
     return(order);
 }
Exemplo n.º 12
0
 public override Node VisitQueryOrderBy(QueryOrderBy orderby) {
   orderby.Source = this.VisitExpression(orderby.Source);
   Composer save = this.contextComposer;
   Composer c = this.contextComposer = this.GetComposer(orderby.Source);
   bool savehcr = this.hasContextReference;
   this.hasContextReference = false;
   this.VisitExpressionList(orderby.OrderList);
   this.hasContextReference = savehcr;
   this.contextComposer = save;
   return this.Compose(orderby, c);
 }    
Exemplo n.º 13
0
 public void Setstock(Expression <Func <TEntity, object> > order, QueryOrderBy sort)
 {
     stock.Add(order, sort);
 }
Exemplo n.º 14
0
 public override Node VisitQueryOrderBy(QueryOrderBy qob) {
   if (qob == null) return null;
   Class cc = this.currentMethod.Scope.ClosureClass;
   qob.Source = this.VisitExpression(qob.Source);
   if (qob.Source == null || qob.Source.Type == null) return null;
   Cardinality card = this.typeSystem.GetCardinality(qob.Source, this.TypeViewer);
   if (card != Cardinality.OneOrMore && card != Cardinality.ZeroOrMore) {
     this.HandleError(qob.Source, Error.QueryNotStream);
   }
   if (qob.OrderList == null || qob.OrderList.Count == 0) {
     this.HandleError(qob, Error.QueryBadOrderList);
     return null;
   }
   for (int i = 0, n = qob.OrderList.Count; i < n; i++) {
     Expression x = qob.OrderList[i];
     if (x == null) {
       this.HandleError(qob, Error.QueryBadOrderList);
       return null;
     }
     QueryOrderItem oi = x as QueryOrderItem;
     if (oi != null) {
       oi.Expression = this.VisitExpression(oi.Expression);
       if (oi.Expression == null || oi.Type == null) return null;
     } else {
       x = this.VisitExpression(x);
       if (x == null || x.Type == null) return null;
     }
     card = this.typeSystem.GetCardinality(x, this.TypeViewer);
     if (card == Cardinality.OneOrMore || card == Cardinality.ZeroOrMore) {
       this.HandleError(x, Error.QueryNotScalar);
       return null;
     }
     qob.OrderList[i] = x;
   }
   if (qob.Type == null) return null;
   return qob;
 }
Exemplo n.º 15
0
 public override Node VisitQueryOrderBy( QueryOrderBy qob ){
   if (qob == null) return null;
   qob.Source = this.VisitExpression(qob.Source);
   QueryGroupBy save = this.currentGroup;
   this.currentGroup = this.GetGroupBySource(qob.Source);
   if (this.currentGroup == null){
     this.currentGroup = new QueryGroupBy();
   }
   this.VisitExpressionList(qob.OrderList);
   if (this.currentGroup.Source == null && this.currentGroup.AggregateList.Count > 0){
     qob.Source = this.InjectGroupBy(qob.Source, this.currentGroup);
   }
   this.currentGroup = save;
   return qob;
 }
Exemplo n.º 16
0
 public virtual Node VisitQueryOrderBy(QueryOrderBy orderby){
   if (orderby == null) return null;
   orderby.Source = this.VisitExpression(orderby.Source);
   orderby.OrderList = this.VisitExpressionList(orderby.OrderList);
   return orderby;
 }
Exemplo n.º 17
0
    public override Node VisitQueryOrderBy(QueryOrderBy qo) {
      // generate translation code
      Block block = null;
      Node closure = this.StartQueryClosure(this.typeSystem.GetStreamElementType(qo, this.TypeViewer), "orderby", out block);
      BlockScope scope = block.Scope;

      // construct list for sorting
      Local locList = new Local(SystemTypes.ArrayList);
      Construct cons = new Construct();
      cons.Constructor = new MemberBinding(null, SystemTypes.ArrayList.GetConstructor());
      cons.Type = SystemTypes.ArrayList;
      block.Statements.Add(new AssignmentStatement(locList, cons));
      
      // build key type
      int len = qo.OrderList.Count;
      FieldList fields = new FieldList(len + 1);
      ArrayList orderTypes = new ArrayList(len);
      ExpressionList expressions = new ExpressionList(len);      
      for( int i = 0; i < len; i++ ) {
        Expression x = qo.OrderList[i];
        QueryOrderType ot = QueryOrderType.Ascending;
        QueryOrderItem order = x as QueryOrderItem;
        if (x != null) {
          ot = order.OrderType;
          x = order.Expression;
        }
        Field f = new Field(null, new AttributeList(1), FieldFlags.Public, Identifier.For("Item"+i), x.Type, null);
        f.Attributes.Add(new AttributeNode(new MemberBinding(null, SystemTypes.AnonymousAttribute.GetConstructor()), null));
        fields.Add(f);
        orderTypes.Add(ot);
        expressions.Add(x);
      }
      Field fRow = new Field(null, new AttributeList(1), FieldFlags.Public, Identifier.For("Item"+len), SystemTypes.Object, null);
      fRow.Attributes.Add(new AttributeNode(new MemberBinding(null, SystemTypes.AnonymousAttribute.GetConstructor()), null));
      fields.Add(fRow);
      
      // construct key type
      TypeNode keyType = TupleType.For(fields, this.currentType);
      
      // build comparer for key
      MemberList members = this.typeSystem.GetDataMembers(keyType);
      fRow = (Field)members[len];
      TypeNode comparerType = this.BuildComparer(keyType, members, (QueryOrderType[])orderTypes.ToArray(typeof(QueryOrderType)), len);
      block.Statements.Add(new QueryGeneratedType(comparerType));

      // iterate rows
      Expression feTarget = null;
      Block inner = null;
      block.Statements.Add(this.BuildClosureForEach(qo.Source, ref feTarget, out inner, scope));
      qo.Context.Target = feTarget;
      
      // prepare key instance
      Expression locKey = new Local(keyType);
      for( int i = 0; i < len; i++ ) {
        Expression x = expressions[i];
        Field f = (Field) members[i];
        inner.Statements.Add(new AssignmentStatement(new MemberBinding(locKey, f), x));
      }
      inner.Statements.Add(new AssignmentStatement(new MemberBinding(locKey, fRow), this.Box(feTarget)));

      // add key to the list
      Method madd = SystemTypes.ArrayList.GetMethod(StandardIds.Add, SystemTypes.Object);
      MethodCall mcAdd = new MethodCall(new MemberBinding(locList, madd), new ExpressionList(this.Box(locKey)));
      mcAdd.Type = madd.ReturnType;
      inner.Statements.Add(new ExpressionStatement(mcAdd));

      // sort the list, now outside original foreach
      Method mthSort = SystemTypes.ArrayList.GetMethod(Identifier.For("Sort"), SystemTypes.IComparer);
      Construct consc = new Construct();
      consc.Constructor = new MemberBinding(null, this.GetTypeView(comparerType).GetConstructor());
      consc.Type = comparerType;
      MethodCall mcSort = new MethodCall(new MemberBinding(locList, mthSort), new ExpressionList(consc));
      mcSort.Type = mthSort.ReturnType;
      block.Statements.Add(new ExpressionStatement(mcSort));

      // now iterate over sorted results
      block.Statements.Add(this.BuildClosureForEach(locList, ref locKey, out inner, scope));
      
      // get row out of key
      inner.Statements.Add(new Yield(this.Unbox(new MemberBinding(locKey, fRow), feTarget.Type)));

      return this.EndQueryClosure(closure, qo.Type);
    }
Exemplo n.º 18
0
 public virtual Node VisitQueryOrderBy(QueryOrderBy orderby, QueryOrderBy changes, QueryOrderBy deletions, QueryOrderBy insertions){
   this.UpdateSourceContext(orderby, changes);
   if (orderby == null) return changes;
   return orderby;
 }
Exemplo n.º 19
0
 public EventingVisitor(Action<QueryOrderBy> visitQueryOrderBy) { VisitedQueryOrderBy += visitQueryOrderBy; } public event Action<QueryOrderBy> VisitedQueryOrderBy; public override Node VisitQueryOrderBy(QueryOrderBy orderby) { if (VisitedQueryOrderBy != null) VisitedQueryOrderBy(orderby); return base.VisitQueryOrderBy(orderby); }