Пример #1
0
 public virtual Net.Vpc.Upa.Expressions.Select From(Net.Vpc.Upa.Expressions.NameOrQuery queryEntity, string alias)
 {
     //getContext().declare(alias, queryEntity);
     this.queryEntity = queryEntity;
     queryEntityAlias = alias;
     return(this);
 }
Пример #2
0
 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);
 }
Пример #3
0
 public JoinCriteria(Net.Vpc.Upa.Expressions.JoinType type, Net.Vpc.Upa.Expressions.NameOrQuery entity, string alias, Net.Vpc.Upa.Expressions.Expression condition)
 {
     this.type      = type;
     this.entity    = entity;
     this.alias     = alias;
     this.condition = condition;
     if (type.Equals(Net.Vpc.Upa.Expressions.JoinType.CROSS_JOIN))
     {
         this.condition = null;
     }
 }
Пример #4
0
 public override void SetChild(Net.Vpc.Upa.Expressions.Expression e, Net.Vpc.Upa.Expressions.ExpressionTag tag)
 {
     if (ENTITY.Equals(tag))
     {
         this.queryEntity = (Net.Vpc.Upa.Expressions.NameOrQuery)e;
     }
     else if (WEHRE.Equals(tag))
     {
         this.where = e;
     }
     else if (HAVING.Equals(tag))
     {
         this.having = e;
     }
     else
     {
         Net.Vpc.Upa.Expressions.IndexedTag ii = (Net.Vpc.Upa.Expressions.IndexedTag)tag;
         string en = ii.GetName();
         if (en.Equals("FIELD"))
         {
             fields[ii.GetIndex()].SetExpression(e);
         }
         else if (en.Equals("JOIN_ENTITY"))
         {
             joinsEntities[ii.GetIndex()].SetEntity((Net.Vpc.Upa.Expressions.NameOrQuery)e);
         }
         else if (en.Equals("JOIN_COND"))
         {
             joinsEntities[ii.GetIndex()].SetCondition(e);
         }
         else if (en.Equals("GROUP"))
         {
             group.SetGroupAt(ii.GetIndex(), e);
         }
         else if (en.Equals("ORDER"))
         {
             order.SetOrderAt(ii.GetIndex(), e);
         }
     }
 }
 protected internal virtual System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.ResultField> CreateResultFields(Net.Vpc.Upa.Expressions.Expression expression, string alias, Net.Vpc.Upa.Filters.FieldFilter fieldFilter, System.Collections.Generic.IList <Net.Vpc.Upa.Expressions.QueryStatement> context)
 {
     expression = expressionManager.ParseExpression(expression);
     System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.ResultField> results = new System.Collections.Generic.List <Net.Vpc.Upa.Persistence.ResultField>();
     if (expression is Net.Vpc.Upa.Expressions.Var)
     {
         Net.Vpc.Upa.Expressions.Var        v      = (Net.Vpc.Upa.Expressions.Var)expression;
         Net.Vpc.Upa.Expressions.Expression parent = v.GetApplier();
         if (parent != null)
         {
             System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.ResultField> parentResults = CreateResultFields(parent, null, fieldFilter, context);
             int size = (parentResults).Count;
             foreach (Net.Vpc.Upa.Persistence.ResultField p in parentResults)
             {
                 if (size > 1)
                 {
                     v = (Net.Vpc.Upa.Expressions.Var)v.Copy();
                 }
                 if (p.GetExpression() != parent)
                 {
                     //change parent
                     v.SetApplier((Net.Vpc.Upa.Expressions.Var)p.GetExpression());
                 }
                 if (p.GetEntity() != null)
                 {
                     if (v.GetName().Equals("*"))
                     {
                         foreach (Net.Vpc.Upa.Field field in p.GetEntity().GetFields(fieldFilter))
                         {
                             results.Add(new Net.Vpc.Upa.Impl.Persistence.DefaultResultField(v, alias, field.GetDataType(), field, null));
                         }
                     }
                     else
                     {
                         Net.Vpc.Upa.Field field = p.GetEntity().GetField(v.GetName());
                         results.Add(new Net.Vpc.Upa.Impl.Persistence.DefaultResultField(v, alias, field.GetDataType(), field, null));
                     }
                 }
                 else if (p.GetField() != null)
                 {
                     if (p.GetField().GetDataType() is Net.Vpc.Upa.Types.ManyToOneType)
                     {
                         Net.Vpc.Upa.Entity entity = ((Net.Vpc.Upa.Types.ManyToOneType)p.GetField().GetDataType()).GetTargetEntity();
                         if (v.GetName().Equals("*"))
                         {
                             foreach (Net.Vpc.Upa.Field field in entity.GetFields(fieldFilter))
                             {
                                 results.Add(new Net.Vpc.Upa.Impl.Persistence.DefaultResultField(v, alias, field.GetDataType(), field, null));
                             }
                         }
                         else
                         {
                             Net.Vpc.Upa.Field field = entity.GetField(v.GetName());
                             results.Add(new Net.Vpc.Upa.Impl.Persistence.DefaultResultField(v, alias, field.GetDataType(), field, null));
                         }
                     }
                     else
                     {
                         results.Add(new Net.Vpc.Upa.Impl.Persistence.DefaultResultField(v, alias, Net.Vpc.Upa.Types.TypesFactory.OBJECT, null, null));
                     }
                 }
                 else
                 {
                     results.Add(new Net.Vpc.Upa.Impl.Persistence.DefaultResultField(v, alias, Net.Vpc.Upa.Types.TypesFactory.OBJECT, null, null));
                 }
             }
         }
         else
         {
             string name = v.GetName();
             System.Collections.Generic.IDictionary <string, Net.Vpc.Upa.Expressions.NameOrQuery> declarations = FindDeclarations(context);
             Net.Vpc.Upa.Expressions.NameOrQuery r = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, Net.Vpc.Upa.Expressions.NameOrQuery>(declarations, name);
             if (r != null)
             {
                 if (r is Net.Vpc.Upa.Expressions.EntityName)
                 {
                     Net.Vpc.Upa.Entity entity = pu.GetEntity(((Net.Vpc.Upa.Expressions.EntityName)r).GetName());
                     results.Add(new Net.Vpc.Upa.Impl.Persistence.DefaultResultField(v, alias, entity.GetDataType(), null, entity));
                 }
                 else
                 {
                     results.Add(new Net.Vpc.Upa.Impl.Persistence.DefaultResultField(v, alias, Net.Vpc.Upa.Types.TypesFactory.OBJECT, null, null));
                 }
             }
             else
             {
                 if ("*".Equals(name))
                 {
                     foreach (System.Collections.Generic.KeyValuePair <string, Net.Vpc.Upa.Expressions.NameOrQuery> entry in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <string, Net.Vpc.Upa.Expressions.NameOrQuery> >(declarations))
                     {
                         r = (entry).Value;
                         if (r is Net.Vpc.Upa.Expressions.EntityName)
                         {
                             Net.Vpc.Upa.Entity entity = pu.GetEntity(((Net.Vpc.Upa.Expressions.EntityName)r).GetName());
                             Net.Vpc.Upa.Field  field  = entity.FindField(name);
                             results.Add(new Net.Vpc.Upa.Impl.Persistence.DefaultResultField(v, alias, field.GetDataType(), field, null));
                             break;
                         }
                     }
                 }
                 else
                 {
                     Net.Vpc.Upa.Field field = null;
                     foreach (System.Collections.Generic.KeyValuePair <string, Net.Vpc.Upa.Expressions.NameOrQuery> entry in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <string, Net.Vpc.Upa.Expressions.NameOrQuery> >(declarations))
                     {
                         r = (entry).Value;
                         if (r is Net.Vpc.Upa.Expressions.EntityName)
                         {
                             Net.Vpc.Upa.Entity entity = pu.GetEntity(((Net.Vpc.Upa.Expressions.EntityName)r).GetName());
                             field = entity.FindField(name);
                             break;
                         }
                     }
                     if (field != null)
                     {
                         results.Add(new Net.Vpc.Upa.Impl.Persistence.DefaultResultField(v, alias, field.GetDataType(), field, null));
                     }
                     else
                     {
                         results.Add(new Net.Vpc.Upa.Impl.Persistence.DefaultResultField(v, alias, Net.Vpc.Upa.Types.TypesFactory.OBJECT, null, null));
                     }
                 }
             }
         }
         return(results);
     }
     results.Add(new Net.Vpc.Upa.Impl.Persistence.DefaultResultField(expression, alias, Net.Vpc.Upa.Types.TypesFactory.OBJECT, null, null));
     return(results);
 }
Пример #6
0
 public virtual string GetMainEntityName()
 {
     Net.Vpc.Upa.Expressions.NameOrQuery t = GetEntity();
     return((t is Net.Vpc.Upa.Expressions.EntityName) ? ((Net.Vpc.Upa.Expressions.EntityName)t).GetName() : null);
 }
Пример #7
0
 private Net.Vpc.Upa.Expressions.Select Join(Net.Vpc.Upa.Expressions.JoinType joinType, Net.Vpc.Upa.Expressions.NameOrQuery entity, string alias, Net.Vpc.Upa.Expressions.Expression condition)
 {
     joinsEntities.Add(new Net.Vpc.Upa.Expressions.JoinCriteria(joinType, entity, alias, condition));
     return(this);
 }
Пример #8
0
 public override string GetEntityName()
 {
     Net.Vpc.Upa.Expressions.NameOrQuery e = GetEntity();
     return((e != null && (e is Net.Vpc.Upa.Expressions.EntityName)) ? ((Net.Vpc.Upa.Expressions.EntityName)e).GetName() : null);
 }
Пример #9
0
 public TreeEntityJoin(Net.Vpc.Upa.Expressions.NameOrQuery table, string var1, string var2, Net.Vpc.Upa.Expressions.Expression expression)  : base(Net.Vpc.Upa.Expressions.JoinType.INNER_JOIN, table, var1, new Net.Vpc.Upa.Impl.Extension.TreeEntityJoinCondition(((Net.Vpc.Upa.Expressions.EntityName)table).GetName(), var1, var2 == null ? var2 + "_ancestor" : var2, expression))
 {
 }
Пример #10
0
 public TreeEntityJoin(Net.Vpc.Upa.Expressions.NameOrQuery table, string var1, Net.Vpc.Upa.Expressions.Expression expression)  : this(table, var1, null, expression)
 {
 }
Пример #11
0
 public virtual void SetEntity(Net.Vpc.Upa.Expressions.NameOrQuery entity)
 {
     this.entity = entity;
 }