public virtual Net.Vpc.Upa.Expressions.Select AddQuery(Net.Vpc.Upa.Expressions.Select other) { if (other == null) { return(this); } if (other.queryEntity != null) { queryEntity = other.queryEntity; } if (other.queryEntityAlias != null) { queryEntityAlias = other.queryEntityAlias; } for (int i = 0; i < (other.joinsEntities).Count; i++) { Net.Vpc.Upa.Expressions.JoinCriteria j = other.GetJoin(i); Join(j.GetJoinType(), j.GetEntity(), j.GetEntityAlias(), j.GetCondition()); } foreach (Net.Vpc.Upa.Expressions.QueryField field in other.fields) { fields.Add(new Net.Vpc.Upa.Expressions.QueryField(field.GetAlias(), field.GetExpression().Copy())); } order.AddOrder(other.order.Copy()); group.AddGroup(other.group.Copy()); this.where = (other.where != null) ? other.where.Copy() : null; this.having = (other.having != null) ? other.having.Copy() : null; return(this); }
public override System.Collections.Generic.IList <Net.Vpc.Upa.Expressions.TaggedExpression> GetChildren() { System.Collections.Generic.IList <Net.Vpc.Upa.Expressions.TaggedExpression> list = new System.Collections.Generic.List <Net.Vpc.Upa.Expressions.TaggedExpression>(); // private Expression where; // private Expression having; // private Order order; if (queryEntity != null) { list.Add(new Net.Vpc.Upa.Expressions.TaggedExpression(queryEntity, ENTITY)); } for (int i = 0; i < (fields).Count; i++) { list.Add(new Net.Vpc.Upa.Expressions.TaggedExpression(fields[i].GetExpression(), new Net.Vpc.Upa.Expressions.IndexedTag("FIELD", i))); } for (int i = 0; i < (joinsEntities).Count; i++) { Net.Vpc.Upa.Expressions.JoinCriteria get = joinsEntities[i]; list.Add(new Net.Vpc.Upa.Expressions.TaggedExpression(get.GetEntity(), new Net.Vpc.Upa.Expressions.IndexedTag("JOIN_ENTITY", i))); list.Add(new Net.Vpc.Upa.Expressions.TaggedExpression(get.GetCondition(), new Net.Vpc.Upa.Expressions.IndexedTag("JOIN_COND", i))); } if (where != null) { list.Add(new Net.Vpc.Upa.Expressions.TaggedExpression(where, WEHRE)); } for (int i = 0; i < group.Size(); i++) { Net.Vpc.Upa.Expressions.Expression ee = group.GetGroupAt(i); list.Add(new Net.Vpc.Upa.Expressions.TaggedExpression(ee, new Net.Vpc.Upa.Expressions.IndexedTag("GROUP", i))); } if (having != null) { list.Add(new Net.Vpc.Upa.Expressions.TaggedExpression(having, HAVING)); } for (int i = 0; i < order.Size(); i++) { Net.Vpc.Upa.Expressions.Expression ee = order.GetOrderAt(i); list.Add(new Net.Vpc.Upa.Expressions.TaggedExpression(ee, new Net.Vpc.Upa.Expressions.IndexedTag("ORDER", i))); } return(list); }
public virtual Net.Vpc.Upa.Expressions.Select Join(Net.Vpc.Upa.Expressions.JoinCriteria someJoin) { Join(someJoin.GetJoinType(), someJoin.GetEntity(), someJoin.GetEntityAlias(), someJoin.GetCondition()); return(this); }
protected internal virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect CompileSelect(Net.Vpc.Upa.Expressions.Select 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.CompiledSelect s = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect(); s.SetDistinct(v.IsDistinct()); s.SetTop(v.GetTop()); Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledNameOrSelect nameOrSelect = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledNameOrSelect)manager.TranslateAny(v.GetEntity(), declarations); string entityAlias = v.GetEntityAlias(); System.Collections.Generic.HashSet <string> aliases = new System.Collections.Generic.HashSet <string>(); if (entityAlias == null) { if (nameOrSelect is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName) { entityAlias = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)nameOrSelect).GetName(); } else { entityAlias = "ALIAS"; } int i = 0; while (true) { string a2 = i == 0 ? entityAlias : (entityAlias + i); if (!aliases.Contains(a2)) { aliases.Add(a2); entityAlias = a2; break; } i++; } } s.From(nameOrSelect, entityAlias); for (int i = 0; i < v.CountJoins(); i++) { Net.Vpc.Upa.Expressions.JoinCriteria c = v.GetJoin(i); Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledNameOrSelect jnameOrSelect = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledNameOrSelect)manager.TranslateAny(c.GetEntity(), declarations); entityAlias = c.GetEntityAlias(); if (entityAlias == null) { if (nameOrSelect is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName) { entityAlias = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)nameOrSelect).GetName(); } else { entityAlias = "ALIAS"; } i = 0; while (true) { string a2 = i == 0 ? entityAlias : (entityAlias + i); if (!aliases.Contains(a2)) { aliases.Add(a2); entityAlias = a2; break; } i++; } } Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledJoinCriteria cc = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledJoinCriteria(c.GetJoinType(), jnameOrSelect, entityAlias, manager.TranslateAny(c.GetCondition(), declarations)); s.Join(cc); } for (int i = 0; i < v.CountFields(); i++) { Net.Vpc.Upa.Expressions.QueryField field = v.GetField(i); s.Field(manager.TranslateAny(field.GetExpression(), declarations), field.GetAlias()); } s.Where(manager.TranslateAny(v.GetWhere(), declarations)); s.Having(manager.TranslateAny(v.GetHaving(), declarations)); for (int i = 0; i < v.CountGroupByItems(); i++) { Net.Vpc.Upa.Expressions.Expression c = v.GetGroupBy(i); s.GroupBy(manager.TranslateAny(c, declarations)); } for (int i = 0; i < v.CountOrderByItems(); i++) { Net.Vpc.Upa.Expressions.Expression c = v.GetOrderBy(i); s.OrderBy(manager.TranslateAny(c, declarations), v.IsOrderAscending(i)); } return(s); }