Ejemplo n.º 1
0
 public Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledUpdate AddQuery(Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledUpdate other)
 {
     if (other == null)
     {
         return(this);
     }
     if (other.entityName != null)
     {
         this.Entity(((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)other.entityName).GetName(), other.entityAlias);
     }
     for (int i = 0; i < (other.fields).Count; i++)
     {
         Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar fvar = other.GetField(i);
         Net.Vpc.Upa.Field field = (Net.Vpc.Upa.Field)fvar.GetReferrer();
         Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression fieldValue = other.GetFieldValue(i);
         Set(field, fieldValue == null ? null : fieldValue.Copy());
     }
     if (other.condition != null)
     {
         if (condition == null)
         {
             Where(other.condition.Copy());
         }
         else
         {
             Where(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledAnd(condition, other.condition.Copy()));
         }
     }
     return(this);
 }
        public override string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext qlContext, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledPlus o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledPlus)oo;
            System.Type t1 = o.GetLeft().GetTypeTransform().GetTargetType().GetPlatformType();
            System.Type t2 = o.GetRight().GetTypeTransform().GetTargetType().GetPlatformType();
            bool        s0 = o.GetTypeTransform().GetTargetType().GetPlatformType().Equals(typeof(string));
            bool        s1 = t1.Equals(typeof(string));
            bool        s2 = t2.Equals(typeof(string));

            if (s0 || s1 || s2)
            {
                Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression c1 = o.GetLeft().Copy();
                Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression c2 = o.GetRight().Copy();
                c1.SetParentExpression(null);
                c2.SetParentExpression(null);
                if (!s1)
                {
                    if (Net.Vpc.Upa.Impl.Util.PlatformUtils.IsAnyInteger(t1))
                    {
                        c1 = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(c1.Copy());
                    }
                    else if (Net.Vpc.Upa.Impl.Util.PlatformUtils.IsAnyFloat(t1))
                    {
                        c1 = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(c1.Copy());
                    }
                    else
                    {
                        throw new System.ArgumentException("Unsupported");
                    }
                }
                if (!s2)
                {
                    if (Net.Vpc.Upa.Impl.Util.PlatformUtils.IsAnyInteger(t2))
                    {
                        c2 = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(c2.Copy());
                    }
                    else if (Net.Vpc.Upa.Impl.Util.PlatformUtils.IsAnyFloat(t2))
                    {
                        c2 = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(c2.Copy());
                    }
                    else
                    {
                        throw new System.ArgumentException("Unsupported");
                    }
                }
                Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat cc = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat(c1, c2);
                return(sqlManager.GetSQL(cc, qlContext, declarations));
            }
            string leftValue = o.GetLeft() != null?sqlManager.GetSQL(o.GetLeft(), qlContext, declarations) : "NULL";

            string rightValue = o.GetRight() != null?sqlManager.GetSQL(o.GetRight(), qlContext, declarations) : "NULL";

            string s = null;

            s = leftValue + " + " + rightValue;
            return("(" + s + ")");
        }
Ejemplo n.º 3
0
 public override Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression Copy()
 {
     Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledBetween o = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledBetween();
     o.SetDescription(GetDescription());
     o.GetClientParameters().SetAll(GetClientParameters());
     o.left = left.Copy();
     o.min  = min.Copy();
     o.max  = max.Copy();
     return(o);
 }
Ejemplo n.º 4
0
 public static Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression TryAddCopies(Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression left, Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression right)
 {
     if (left != null)
     {
         left = left.Copy();
     }
     if (right != null)
     {
         right = right.Copy();
     }
     return(TryAdd(left, right));
 }
Ejemplo n.º 5
0
 public virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect AddQuery(Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect other)
 {
     if (other == null)
     {
         return(this);
     }
     if (other.queryEntity != null)
     {
         From((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledNameOrSelect)(other.queryEntity.Copy()), other.queryEntityAlias);
     }
     for (int i = 0; i < (other.joinsTables).Count; i++)
     {
         Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledJoinCriteria      j  = other.GetJoin(i);
         Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledNameOrSelect      ee = j.GetEntity();
         Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression cc = j.GetCondition();
         Join(j.GetJoinType(), ee == null ? null : (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledNameOrSelect)ee.Copy(), j.GetEntityAlias(), cc == null ? null : cc.Copy());
     }
     foreach (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQueryField field in other.fields)
     {
         Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression ee = field.GetExpression();
         AddField(ee == null ? null : ee.Copy(), field.GetAlias());
     }
     foreach (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledOrderItem compiledOrderItem in other.order.GetItems())
     {
         Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression ee = compiledOrderItem.GetExpression();
         OrderBy(ee == null ? null : ee.Copy(), compiledOrderItem.IsAsc());
     }
     foreach (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression e in other.groupByExpressions)
     {
         GroupBy(e == null ? null : e.Copy());
     }
     AddWhere(other.where == null ? null : other.where.Copy());
     AddHaving(other.having == null ? null : other.having.Copy());
     Invalidate();
     return(this);
 }
Ejemplo n.º 6
0
 public virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledOrderItem Copy()
 {
     return(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledOrderItem(expression.Copy(), asc));
 }
Ejemplo n.º 7
0
 public override Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression Copy()
 {
     return(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarVal(var == null ? null : ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)var.Copy()), val == null ? null : ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression)val.Copy())));
 }
Ejemplo n.º 8
0
 public override Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression Copy()
 {
     return(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledJoinCriteria(joinType, (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledNameOrSelect)(entity == null ? null : entity.Copy()), alias, condition == null ? null : condition.Copy()));
 }
 public override Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression Copy()
 {
     return(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.IsHierarchyDescendentCompiled(ancestorExpression.Copy(), childExpression.Copy(), (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)entityName.Copy()));
 }
Ejemplo n.º 10
0
 public override Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression Copy()
 {
     Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInCollection o = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInCollection(left.Copy());
     o.SetDescription(GetDescription());
     o.GetClientParameters().SetAll(GetClientParameters());
     foreach (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression expression in right)
     {
         o.Add(expression.Copy());
     }
     return(o);
 }
 public virtual Net.Vpc.Upa.Expressions.CompiledExpression CreateConditionForDeepSearch(Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression alias, Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression id, bool includeId, Net.Vpc.Upa.Field field, string pathSep) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     alias = alias.Copy();
     if (alias is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)
     {
         Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar cv = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)alias;
         if (cv.GetReferrer() is Net.Vpc.Upa.Entity)
         {
             Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar v = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(field.GetName());
             ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)alias).SetChild(v);
         }
         else
         {
             throw new System.ArgumentException("Expected " + field.GetEntity().GetName() + " var name");
         }
     }
     else
     {
         throw new System.ArgumentException("Expected " + field.GetEntity().GetName() + " var name");
     }
     id = id.Copy();
     System.Collections.Generic.IList <Net.Vpc.Upa.Field> primaryFields = field.GetEntity().GetPrimaryFields();
     if ((primaryFields).Count > 1)
     {
         throw new System.ArgumentException("Composite ID unsupported for function treeancestor");
     }
     Net.Vpc.Upa.Types.DataType pkType = primaryFields[0].GetDataType();
     Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression strId = null;
     if (pkType is Net.Vpc.Upa.Types.IntType)
     {
         strId = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(id);
     }
     else if (pkType is Net.Vpc.Upa.Types.LongType)
     {
         strId = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(id);
     }
     else if (pkType is Net.Vpc.Upa.Types.ShortType)
     {
         strId = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(id);
     }
     else if (pkType is Net.Vpc.Upa.Types.ByteType)
     {
         strId = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(id);
     }
     else if (pkType is Net.Vpc.Upa.Types.FloatType)
     {
         strId = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledD2V(id);
     }
     else if (pkType is Net.Vpc.Upa.Types.DoubleType)
     {
         strId = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledD2V(id);
     }
     else if (pkType is Net.Vpc.Upa.Types.StringType)
     {
         strId = id;
     }
     else
     {
         strId = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledCast(id, Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform.STRING);
     }
     if (includeId)
     {
         return(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledOr(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLike(alias.Copy(), new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral("%" + pathSep), strId.Copy())), new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLike(alias.Copy(), new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral("%" + pathSep), strId.Copy(), new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(pathSep + "%")))));
     }
     else
     {
         return(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLike(alias.Copy(), new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral("%" + pathSep), strId.Copy(), new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(pathSep + "%"))));
     }
 }