private Net.Vpc.Upa.Expressions.IdCollectionExpression CreateInCollection(Net.Vpc.Upa.Entity entity, System.Collections.Generic.ICollection <Net.Vpc.Upa.Key> collection) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { System.Collections.Generic.IList <Net.Vpc.Upa.Field> pfs = entity.GetPrimaryFields(); Net.Vpc.Upa.Expressions.Var[] v = new Net.Vpc.Upa.Expressions.Var[(pfs).Count]; for (int i = 0; i < (pfs).Count; i++) { v[i] = new Net.Vpc.Upa.Expressions.Var(new Net.Vpc.Upa.Expressions.Var(pfs[i].GetEntity().GetName()), pfs[i].GetName()); } if ((pfs).Count == 1) { Net.Vpc.Upa.Expressions.IdCollectionExpression inColl = new Net.Vpc.Upa.Expressions.IdCollectionExpression(v[0]); //inColl.setClientProperty(DefaultEntity.EXPRESSION_SURELY_EXISTS, true); foreach (Net.Vpc.Upa.Key k in collection) { inColl.Add(new Net.Vpc.Upa.Expressions.Literal(k.GetObject(), pfs[0].GetDataType())); } return(inColl); } else { Net.Vpc.Upa.Expressions.IdCollectionExpression inColl = new Net.Vpc.Upa.Expressions.IdCollectionExpression(v); //inColl.setClientProperty(DefaultEntity.EXPRESSION_SURELY_EXISTS, true); foreach (Net.Vpc.Upa.Key k in collection) { Net.Vpc.Upa.Expressions.Literal[] l = new Net.Vpc.Upa.Expressions.Literal[(pfs).Count]; for (int j = 0; j < (pfs).Count; j++) { l[j] = new Net.Vpc.Upa.Expressions.Literal(k.GetObjectAt(j), pfs[j].GetDataType()); } inColl.Add(l); } return(inColl); } }
public StrFormat(Net.Vpc.Upa.Expressions.Expression[] expressions) { if (expressions.Length < 1) { CheckArgCount(GetName(), expressions, 1); } this.pattern = (Net.Vpc.Upa.Expressions.Literal)expressions[0]; this.expressions = new Net.Vpc.Upa.Expressions.Expression[expressions.Length - 1]; System.Array.Copy(this.expressions, 1, this.expressions, 0, expressions.Length - 1); }
public override void SetArgument(int index, Net.Vpc.Upa.Expressions.Expression e) { if (index == 0) { this.pattern = (Net.Vpc.Upa.Expressions.Literal)e; } else { expressions[index - 1] = e; } }
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; }
public StrFormat(string pattern, params Net.Vpc.Upa.Expressions.Expression [] expressions) { this.expressions = expressions; this.pattern = new Net.Vpc.Upa.Expressions.Literal(pattern); }
public virtual Net.Vpc.Upa.Expressions.Expression GetSourceCondition(Net.Vpc.Upa.Expressions.Expression targetCondition, string sourceAlias, string targetAlias) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { //Key Rkey=getTargetTable().getKeyForExpression(targetCondition); Net.Vpc.Upa.Field[] sourceFields = GetSourceRole().GetFields().ToArray(); Net.Vpc.Upa.Field[] targetFields = GetTargetRole().GetFields().ToArray(); if (targetCondition is Net.Vpc.Upa.Expressions.IdExpression) { Net.Vpc.Upa.Key Rkey = targetRole.GetEntity().GetBuilder().IdToKey(((Net.Vpc.Upa.Expressions.IdExpression)targetCondition).GetId()); if (sourceFields.Length == 1) { Net.Vpc.Upa.Expressions.Var lvar = (sourceAlias == null) ? new Net.Vpc.Upa.Expressions.Var(sourceFields[0].GetName()) : new Net.Vpc.Upa.Expressions.Var(new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[0].GetName()); return(new Net.Vpc.Upa.Expressions.Equals(lvar, new Net.Vpc.Upa.Expressions.Literal(Rkey == null ? null : Rkey.GetValue()[0], targetFields[0].GetDataType()))); } else { Net.Vpc.Upa.Expressions.Expression a = null; for (int i = 0; i < sourceFields.Length; i++) { Net.Vpc.Upa.Expressions.Var lvar = (sourceAlias == null) ? new Net.Vpc.Upa.Expressions.Var(sourceFields[i].GetName()) : new Net.Vpc.Upa.Expressions.Var(new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[i].GetName()); Net.Vpc.Upa.Expressions.Expression rvar = new Net.Vpc.Upa.Expressions.Literal(Rkey == null ? null : Rkey.GetObjectAt(i), targetFields[i].GetDataType()); Net.Vpc.Upa.Expressions.Expression e = new Net.Vpc.Upa.Expressions.Equals(lvar, rvar); a = a == null ? e : a; } return(a); } } else if (tuningMaxInline > 0) { Net.Vpc.Upa.Expressions.Var[] lvar = new Net.Vpc.Upa.Expressions.Var[sourceFields.Length]; Net.Vpc.Upa.Expressions.Var[] rvar = new Net.Vpc.Upa.Expressions.Var[targetFields.Length]; for (int i = 0; i < lvar.Length; i++) { lvar[i] = new Net.Vpc.Upa.Expressions.Var((sourceAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[i].GetName()); rvar[i] = new Net.Vpc.Upa.Expressions.Var((targetAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(targetAlias), targetFields[i].GetName()); } try { System.Collections.Generic.IList <Net.Vpc.Upa.Record> list = GetTargetRole().GetEntity().CreateQuery(new Net.Vpc.Upa.Expressions.Select().Uplet(rvar, "rval").Where(targetCondition)).GetRecordList(); int j = 0; Net.Vpc.Upa.Expressions.IdCollectionExpression inCollection = new Net.Vpc.Upa.Expressions.IdCollectionExpression(lvar); foreach (Net.Vpc.Upa.Record r in list) { j++; if (j > tuningMaxInline) { return(new Net.Vpc.Upa.Expressions.InSelection(lvar, new Net.Vpc.Upa.Expressions.Select().From(GetTargetRole().GetEntity().GetName()).Uplet(rvar).Where(targetCondition))); } inCollection.Add(new Net.Vpc.Upa.Expressions.Param(null, r.GetSingleResult <T>())); } //inCollection.add(new Litteral(rs.getObject(1))); return(inCollection); } catch (Net.Vpc.Upa.Exceptions.UPAException e) { return(new Net.Vpc.Upa.Expressions.InSelection(lvar, new Net.Vpc.Upa.Expressions.Select().From(GetTargetRole().GetEntity().GetName()).Uplet(rvar).Where(targetCondition))); } } else { Net.Vpc.Upa.Expressions.Var[] lvar = new Net.Vpc.Upa.Expressions.Var[sourceFields.Length]; Net.Vpc.Upa.Expressions.Var[] rvar = new Net.Vpc.Upa.Expressions.Var[targetFields.Length]; for (int i = 0; i < lvar.Length; i++) { lvar[i] = new Net.Vpc.Upa.Expressions.Var((sourceAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[i].GetName()); rvar[i] = new Net.Vpc.Upa.Expressions.Var((targetAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(targetAlias), targetFields[i].GetName()); } return(new Net.Vpc.Upa.Expressions.InSelection(lvar, new Net.Vpc.Upa.Expressions.Select().From(GetTargetRole().GetEntity().GetName()).Uplet(rvar).Where(targetCondition))); } }
protected internal virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral CompileLiteral(Net.Vpc.Upa.Expressions.Literal v, Net.Vpc.Upa.Impl.Uql.ExpressionTranslationManager manager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) { if (v == null) { return(null); } Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral s = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(v.GetValue(), null); // s.setDeclarationList(declarations); return(s); }