public static Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect FindEnclosingSelect(Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar v) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression e = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression)v; Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar rv = FindRootVar(v); while (e != null) { if (e is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect s = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect)e; string entityAlias = s.GetEntityAlias(); if (entityAlias != null && (entityAlias).Length > 0) { if (rv.GetName().Equals(entityAlias)) { return(s); } } else { if (rv.GetName().Equals(s.GetEntityName())) { return(s); } } foreach (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledJoinCriteria c in s.GetJoins()) { string joinAlias = c.GetEntityAlias(); if (joinAlias != null && (joinAlias).Length > 0) { if (rv.GetName().Equals(joinAlias)) { return(s); } } else { if (rv.GetName().Equals(c.GetEntityName())) { return(s); } } } } e = e.GetParentExpression(); } return(null); }