Exemplo n.º 1
0
 public Net.Vpc.Upa.Expressions.Update AddQuery(Net.Vpc.Upa.Expressions.Update other)
 {
     if (other == null)
     {
         return(this);
     }
     if (other.entity != null)
     {
         entity = (Net.Vpc.Upa.Expressions.EntityName)other.entity.Copy();
     }
     if (other.entityAlias != null)
     {
         entityAlias = other.entityAlias;
     }
     for (int i = 0; i < (other.fields).Count; i++)
     {
         Set(other.GetField(i).GetName(), other.GetFieldValue(i));
     }
     if (other.condition != null)
     {
         if (condition == null)
         {
             condition = other.condition.Copy();
         }
         else
         {
             condition = new Net.Vpc.Upa.Expressions.And(condition, other.condition.Copy());
         }
     }
     return(this);
 }
Exemplo n.º 2
0
        protected internal virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityStatement CreateCompiledEntityStatement()
        {
            Net.Vpc.Upa.Persistence.ExpressionCompilerConfig config = new Net.Vpc.Upa.Persistence.ExpressionCompilerConfig();
            string alias = null;
            string ent   = null;

            if (query is Net.Vpc.Upa.Expressions.Select)
            {
                Net.Vpc.Upa.Expressions.Select d = (Net.Vpc.Upa.Expressions.Select)query;
                string entityAlias = d.GetEntityAlias();
                Net.Vpc.Upa.Expressions.EntityName entityName = (d.GetEntity() is Net.Vpc.Upa.Expressions.EntityName) ? ((Net.Vpc.Upa.Expressions.EntityName)d.GetEntity()) : null;
                if (entityAlias != null)
                {
                    alias = entityAlias;
                    ent   = entityName == null ? null : entityName.GetName();
                }
                else
                {
                    ent   = entityName == null ? null : entityName.GetName();
                    alias = ent;
                }
            }
            if (alias != null)
            {
                config.SetThisAlias(alias);
            }
            config.SetExpandFields(false);
            config.SetExpandEntityFilter(false);
            config.SetValidate(false);
            return((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityStatement)context.GetPersistenceUnit().GetExpressionManager().CompileExpression(query, config));
        }
Exemplo n.º 3
0
 public override void SetChild(Net.Vpc.Upa.Expressions.Expression e, Net.Vpc.Upa.Expressions.ExpressionTag tag)
 {
     if (ENTITY.Equals(tag))
     {
         this.entity = (Net.Vpc.Upa.Expressions.EntityName)e;
     }
     else if (COND.Equals(tag))
     {
         this.condition = e;
     }
 }
Exemplo n.º 4
0
 public override void SetChild(Net.Vpc.Upa.Expressions.Expression e, Net.Vpc.Upa.Expressions.ExpressionTag tag)
 {
     if (ENTITY.Equals(tag))
     {
         this.entity = (Net.Vpc.Upa.Expressions.EntityName)e;
     }
     else if (SELECTION.Equals(tag))
     {
         this.selection = (Net.Vpc.Upa.Expressions.QueryStatement)e;
     }
     else
     {
         Net.Vpc.Upa.Expressions.IndexedTag ii = (Net.Vpc.Upa.Expressions.IndexedTag)tag;
         fields[ii.GetIndex()] = (Net.Vpc.Upa.Expressions.Var)e;
     }
 }
Exemplo n.º 5
0
 public virtual Net.Vpc.Upa.Expressions.Insert AddQuery(Net.Vpc.Upa.Expressions.Insert other)
 {
     if (other == null)
     {
         return(this);
     }
     if (other.entity != null)
     {
         entity = (Net.Vpc.Upa.Expressions.EntityName)other.entity.Copy();
     }
     for (int i = 0; i < (other.fields).Count; i++)
     {
         Set(other.GetField(i).GetName(), other.GetFieldValue(i).Copy());
     }
     return(this);
 }
Exemplo n.º 6
0
 public virtual Net.Vpc.Upa.Expressions.Delete AddQuery(Net.Vpc.Upa.Expressions.Delete other)
 {
     if (other == null)
     {
         return(this);
     }
     if (other.entity != null)
     {
         entity = (Net.Vpc.Upa.Expressions.EntityName)other.entity.Copy();
     }
     if (other.entityAlias != null)
     {
         entityAlias = other.entityAlias;
     }
     other.condition = condition.Copy();
     return(this);
 }
Exemplo n.º 7
0
 public override void SetChild(Net.Vpc.Upa.Expressions.Expression e, Net.Vpc.Upa.Expressions.ExpressionTag tag)
 {
     if (ENTITY.Equals(tag))
     {
         this.entity = (Net.Vpc.Upa.Expressions.EntityName)e;
     }
     else
     {
         Net.Vpc.Upa.Expressions.IndexedTag ii = (Net.Vpc.Upa.Expressions.IndexedTag)tag;
         if (ii.GetName().Equals("VAR"))
         {
             fields[ii.GetIndex()].SetVar((Net.Vpc.Upa.Expressions.Var)e);
         }
         else
         {
             fields[ii.GetIndex()].SetVal(e);
         }
     }
 }
Exemplo n.º 8
0
 private void Init(Net.Vpc.Upa.Expressions.Expression ancestorExpression, Net.Vpc.Upa.Expressions.Expression childExpression, Net.Vpc.Upa.Expressions.Expression entityName)
 {
     if (entityName != null)
     {
         if (entityName is Net.Vpc.Upa.Expressions.EntityName)
         {
             this.entityName = (Net.Vpc.Upa.Expressions.EntityName)entityName;
         }
         else if (entityName is Net.Vpc.Upa.Expressions.Var)
         {
             Net.Vpc.Upa.Expressions.Var v = (Net.Vpc.Upa.Expressions.Var)entityName;
             if (v.GetApplier() != null)
             {
                 throw new Net.Vpc.Upa.Exceptions.IllegalArgumentException("Invalid EntityName");
             }
             this.entityName = new Net.Vpc.Upa.Expressions.EntityName(v.GetName());
         }
         else if (entityName is Net.Vpc.Upa.Expressions.Literal)
         {
             Net.Vpc.Upa.Expressions.Literal v = (Net.Vpc.Upa.Expressions.Literal)entityName;
             if (!(v.GetValue() is string))
             {
                 throw new Net.Vpc.Upa.Exceptions.IllegalArgumentException("Invalid EntityName");
             }
             this.entityName = new Net.Vpc.Upa.Expressions.EntityName((string)v.GetValue());
         }
         else
         {
             throw new Net.Vpc.Upa.Exceptions.IllegalArgumentException("Invalid EntityName");
         }
     }
     else
     {
         this.entityName = new Net.Vpc.Upa.Expressions.EntityName("");
     }
     this.ancestorExpression = ancestorExpression;
     this.childExpression    = childExpression;
 }
Exemplo n.º 9
0
 public virtual Net.Vpc.Upa.Expressions.InsertSelection AddQuery(Net.Vpc.Upa.Expressions.InsertSelection other)
 {
     if (other == null)
     {
         return(this);
     }
     if (other.entity != null)
     {
         entity = other.entity;
     }
     if (other.alias != null)
     {
         alias = other.alias;
     }
     for (int i = 0; i < (other.fields).Count; i++)
     {
         Field(other.GetField(i).GetName());
     }
     if (other.selection != null)
     {
         selection = (Net.Vpc.Upa.Expressions.QueryStatement)other.selection.Copy();
     }
     return(this);
 }
Exemplo n.º 10
0
        public override void SetArgument(int index, Net.Vpc.Upa.Expressions.Expression e)
        {
            switch (index)
            {
            case 0:
            {
                this.ancestorExpression = e;
                break;
            }

            case 1:
            {
                this.childExpression = e;
                break;
            }

            case 2:
            {
                this.entityName = (Net.Vpc.Upa.Expressions.EntityName)e;
                break;
            }
            }
            throw new System.IndexOutOfRangeException();
        }
Exemplo n.º 11
0
        public override string ToString()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder("Select ");
            if (top > 0)
            {
                sb.Append(" TOP ").Append(top);
            }
            if (distinct)
            {
                sb.Append(" DISTINCT");
            }
            sb.Append(" ");
            string aliasString = null;
            string valueString = null;
            bool   started     = false;

            if (CountFields() == 0)
            {
                sb.Append("...");
            }
            else
            {
                for (int i = 0; i < CountFields(); i++)
                {
                    Net.Vpc.Upa.Expressions.QueryField fi = GetField(i);
                    Net.Vpc.Upa.Expressions.Expression e  = fi.GetExpression();
                    valueString = System.Convert.ToString(e);
                    aliasString = fi.GetAlias();
                    if (started)
                    {
                        sb.Append(",");
                    }
                    else
                    {
                        started = true;
                    }
                    if (aliasString == null)
                    {
                        sb.Append(valueString);
                    }
                    else
                    {
                        sb.Append(valueString);
                        sb.Append(" ");
                        sb.Append(Net.Vpc.Upa.Expressions.ExpressionHelper.EscapeIdentifier(aliasString));
                    }
                }
            }
            if (GetEntity() == null)
            {
            }
            else
            {
                sb.Append(" From ");
                if (GetEntity() is Net.Vpc.Upa.Expressions.Select)
                {
                    sb.Append(GetEntity().ToString());
                }
                else
                {
                    Net.Vpc.Upa.Expressions.EntityName entityName = (Net.Vpc.Upa.Expressions.EntityName)GetEntity();
                    sb.Append(entityName);
                }
            }
            if (GetEntityAlias() != null)
            {
                sb.Append(" ").Append(Net.Vpc.Upa.Expressions.ExpressionHelper.EscapeIdentifier(GetEntityAlias()));
            }
            for (int i = 0; i < CountJoins(); i++)
            {
                Net.Vpc.Upa.Expressions.JoinCriteria e = GetJoin(i);
                sb.Append(" ").Append(e);
            }
            Net.Vpc.Upa.Expressions.Expression c = GetWhere();
            if (c != null && c.IsValid())
            {
                sb.Append(" Where ").Append(c);
            }
            if (CountGroupByItems() > 0)
            {
                sb.Append(" ");
                int maxGroups = CountGroupByItems();
                sb.Append("Group By ");
                for (int i = 0; i < maxGroups; i++)
                {
                    if (i > 0)
                    {
                        sb.Append(", ");
                    }
                    sb.Append(GetGroupBy(i));
                }
            }
            int maxOrders = CountOrderByItems();

            if (maxOrders > 0)
            {
                sb.Append(" ");
                sb.Append("Order By ");
                for (int i = 0; i < maxOrders; i++)
                {
                    if (i > 0)
                    {
                        sb.Append(", ");
                    }
                    sb.Append(GetOrderBy(i));
                    if (IsOrderAscending(i))
                    {
                        sb.Append(" Asc ");
                    }
                    else
                    {
                        sb.Append(" Desc ");
                    }
                }
            }
            return(sb.ToString());
        }
Exemplo n.º 12
0
 public override string GetEntityName()
 {
     Net.Vpc.Upa.Expressions.EntityName e = GetEntity();
     return((e != null) ? ((Net.Vpc.Upa.Expressions.EntityName)e).GetName() : null);
 }
Exemplo n.º 13
0
 private Net.Vpc.Upa.Expressions.InsertSelection Into(string entity, string alias)
 {
     this.entity = new Net.Vpc.Upa.Expressions.EntityName(entity);
     this.alias  = alias;
     return(this);
 }
Exemplo n.º 14
0
 public virtual Net.Vpc.Upa.Expressions.Insert Into(string entity)
 {
     this.entity = new Net.Vpc.Upa.Expressions.EntityName(entity);
     return(this);
 }
Exemplo n.º 15
0
 private Net.Vpc.Upa.Expressions.Update Entity(string entity, string alias)
 {
     this.entity = new Net.Vpc.Upa.Expressions.EntityName(entity);
     entityAlias = alias;
     return(this);
 }
Exemplo n.º 16
0
 public void SetEntityName(Net.Vpc.Upa.Expressions.EntityName entityName)
 {
     this.entityName = entityName;
 }
Exemplo n.º 17
0
 public Delete()
 {
     entity      = null;
     entityAlias = null;
 }
Exemplo n.º 18
0
 public override Net.Vpc.Upa.Expressions.Expression Copy()
 {
     Net.Vpc.Upa.Expressions.EntityName o = new Net.Vpc.Upa.Expressions.EntityName(name);
     return(o);
 }
 protected internal virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName CompileEntityName(Net.Vpc.Upa.Expressions.EntityName v, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations)
 {
     if (v == null)
     {
         return(null);
     }
     Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName s = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(v.GetName());
     //        s.setDeclarationList(declarations);
     return(s);
 }