public virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInsertSelection AddQuery(Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInsertSelection other) { if (other == null) { return(this); } if (other.entity != null) { entity = other.entity; if (other.tableAlias != null) { tableAlias = other.tableAlias; } PrepareChildren(this.entity); ExportDeclaration(tableAlias, Net.Vpc.Upa.Impl.Uql.DecObjectType.ENTITY, other.entity.GetName(), null); } for (int i = 0; i < (other.fields).Count; i++) { Field(other.GetField(i).GetName()); } if (other.selection != null) { selection = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQueryStatement)other.selection.Copy(); } return(this); }
private Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInsert Into(string entity, string alias) { this.entity = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(entity); PrepareChildren(this.entity); ExportDeclaration(alias, Net.Vpc.Upa.Impl.Uql.DecObjectType.ENTITY, entity, alias); return(this); }
private Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledDelete From(string entityName, string alias) { this.entity = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(entityName); entityAlias = alias; ExportDeclaration(alias, Net.Vpc.Upa.Impl.Uql.DecObjectType.ENTITY, entityName, null); PrepareChildren(entity); return(this); }
private Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledUpdate Entity(string entity, string alias) { this.entityName = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(entity); entityAlias = alias; PrepareChildren(this.entityName); ExportDeclaration(entityAlias, Net.Vpc.Upa.Impl.Uql.DecObjectType.ENTITY, ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName) this.entityName).GetName(), null); return(this); }
public override Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression Copy() { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName o = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(name); o.SetDescription(GetDescription()); o.GetClientParameters().SetAll(GetClientParameters()); o.SetUseView(isUseView); return(o); }
public virtual string GetEntityName() { if (entity != null && entity is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName s = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)entity; return(s.GetName()); } return(null); }
public IsHierarchyDescendentCompiled(Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression ancestorExpression, Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression childExpression, Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName entityName) : base("treeAncestor") { this.ancestorExpression = ancestorExpression; this.childExpression = childExpression; this.entityName = entityName; ProtectedAddArgument(ancestorExpression); ProtectedAddArgument(childExpression); ProtectedAddArgument(entityName); }
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); }
public override void SetSubExpression(int index, Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression expression) { if (index == 0) { entity = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)expression; PrepareChildren(expression); } else { fields[index - 1] = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarVal)expression; PrepareChildren(expression); } }
public override void SetSubExpression(int index, Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression expression) { if (index == 0) { entity = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)expression; } else if (index - 1 < (fields).Count) { fields[index - 1] = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)expression; } else { selection = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect)expression; } }
public override string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext context, 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.CompiledEntityName o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)oo; Net.Vpc.Upa.Persistence.PersistenceStore persistenceStore = context.GetPersistenceStore(); string entityName = o.GetName(); Net.Vpc.Upa.Entity e = context.GetPersistenceUnit().GetEntity(entityName); if (o.IsUseView() && e.NeedsView() && persistenceStore.IsViewSupported()) { return(persistenceStore.GetValidIdentifier(persistenceStore.GetPersistenceName(e, Net.Vpc.Upa.Persistence.PersistenceNameType.IMPLICIT_VIEW))); } else { return(persistenceStore.GetValidIdentifier(persistenceStore.GetPersistenceName(e))); } }
public virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInsert AddQuery(Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInsert other) { if (other == null) { return(this); } if (other.entity != null) { entity = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)other.entity.Copy(); ExportDeclaration(null, Net.Vpc.Upa.Impl.Uql.DecObjectType.ENTITY, entity.GetName(), null); PrepareChildren(entity); } for (int i = 0; i < (other.fields).Count; i++) { Set(other.GetField(i).GetName(), other.GetFieldValue(i).Copy()); } return(this); }
protected internal virtual void AppendFrom(Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect o, System.Text.StringBuilder sb, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledNameOrSelect entity = o.GetEntity(); if (entity == null) { string fns = GetFromNullString(); if (fns != null) { sb.Append(" "); sb.Append(fns); } } else { sb.Append(" From "); if (entity is Net.Vpc.Upa.Expressions.Select) { sb.Append(sqlManager.GetSQL(entity, context, declarations)); } else { Net.Vpc.Upa.Persistence.PersistenceStore persistenceStore = context.GetPersistenceStore(); Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName entityName = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)entity; Net.Vpc.Upa.Entity e = context.GetPersistenceUnit().GetEntity(entityName.GetName()); if (entityName.IsUseView() && e.NeedsView() && persistenceStore.IsViewSupported()) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName v = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(e.GetName(), true); sb.Append(sqlManager.GetSQL(v, context, declarations)); } else { sb.Append(sqlManager.GetSQL(entityName, context, declarations)); } } } if (o.GetEntityAlias() != null) { Net.Vpc.Upa.Persistence.PersistenceStore store = context.GetPersistenceStore(); sb.Append(" ").Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(o.GetEntityAlias()), context, declarations)); } }
public override void SetSubExpression(int index, Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression expression) { int i = 0; if (entity != null) { if (i == index) { entity = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)expression; } i++; } if (condition != null) { if (i == index) { condition = expression; } i++; } }
public CompiledDelete() { entity = null; entityAlias = null; }
public virtual Net.Vpc.Upa.Expressions.CompiledExpression Update(Net.Vpc.Upa.Expressions.CompiledExpression e) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.IsHierarchyDescendentCompiled o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.IsHierarchyDescendentCompiled)e; Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression c = o.GetChildExpression(); Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression p = o.GetAncestorExpression(); Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName n = o.GetEntityName(); Net.Vpc.Upa.Entity treeEntity = null; Net.Vpc.Upa.Field treeField = null; if (c is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar) { object childReferrer = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)c).GetFinest().GetReferrer(); if (childReferrer != null) { if (childReferrer is Net.Vpc.Upa.Entity) { if (treeEntity == null) { treeEntity = (Net.Vpc.Upa.Entity)childReferrer; } else { if (!treeEntity.GetName().Equals(((Net.Vpc.Upa.Entity)childReferrer).GetName())) { throw new System.ArgumentException("Ambiguous or Invalid Type " + treeEntity.GetName() + " in TreeEntity near " + e); } } } } } else if (c is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam) { object co = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)c).GetValue(); if (co != null && persistenceUnit.ContainsEntity(co.GetType())) { Net.Vpc.Upa.Entity rr = persistenceUnit.GetEntity(co.GetType()); if (treeEntity == null) { treeEntity = rr; } ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)c).SetValue(rr.GetBuilder().ObjectToId(co)); } } // Object co = ((CompiledParam) c).getEffectiveDataType(); if (p is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar) { object parentReferrer = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)p).GetFinest().GetReferrer(); if (parentReferrer != null) { if (parentReferrer is Net.Vpc.Upa.Entity) { if (treeEntity == null) { treeEntity = (Net.Vpc.Upa.Entity)parentReferrer; } else { if (!treeEntity.GetName().Equals(((Net.Vpc.Upa.Entity)parentReferrer).GetName())) { throw new System.ArgumentException("Ambiguous or Invalid Type " + treeEntity.GetName() + " in TreeEntity near " + e); } } } } } else if (p is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam) { object co = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)p).GetValue(); if (co != null && persistenceUnit.ContainsEntity(co.GetType())) { Net.Vpc.Upa.Entity rr = persistenceUnit.FindEntity(co.GetType()); if (treeEntity == null) { treeEntity = rr; } ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)p).SetValue(rr.GetBuilder().ObjectToId(co)); if ((rr.GetPrimaryFields()).Count > 1) { throw new System.ArgumentException("Not supported"); } ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)p).SetTypeTransform(Net.Vpc.Upa.Impl.Util.UPAUtils.GetTypeTransformOrIdentity(rr.GetPrimaryFields()[0])); } } // Object co = ((CompiledParam) c).getEffectiveDataType(); if (treeEntity == null) { treeEntity = persistenceUnit.GetEntity(n.GetName()); } Net.Vpc.Upa.Relationship t = Net.Vpc.Upa.Impl.Extension.HierarchicalRelationshipSupport.GetTreeRelationName(treeEntity); if (t == null) { throw new System.ArgumentException("Hierarchy Relationship not found"); } Net.Vpc.Upa.Extensions.HierarchyExtension s = t.GetHierarchyExtension(); if (s == null) { throw new System.ArgumentException("Not a valid TreeEntity"); } Net.Vpc.Upa.Field pathField = treeEntity.GetField(s.GetHierarchyPathField()); string pathSep = s.GetHierarchyPathSeparator(); return(CreateConditionForDeepSearch(c, (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression)p, true, pathField, pathSep)); }
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.Impl.Uql.Compiledexpression.CompiledQueryField fi = GetField(i); Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression e = fi.GetExpression(); valueString = System.Convert.ToString(e); if (!(e is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar) && !(e is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam) && !(e is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledFunction) && !(e is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral)) { valueString = "(" + valueString + ")"; } aliasString = fi.GetAlias(); if (started) { sb.Append(","); } else { started = true; } if (aliasString == null) { sb.Append(valueString); } else { sb.Append(valueString); sb.Append(" "); sb.Append(aliasString); } } } if (GetEntity() == null) { } else { sb.Append(" From "); if (GetEntity() is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect) { sb.Append(GetEntity().ToString()); } else { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName entityName = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)GetEntity(); sb.Append(entityName); } } if (GetEntityAlias() != null) { sb.Append(" ").Append(GetEntityAlias()); } for (int i = 0; i < CountJoins(); i++) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledJoinCriteria e = GetJoin(i); sb.Append(" ").Append(e); } Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression 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()); }