예제 #1
0
 public virtual Net.Vpc.Upa.Impl.Persistence.RebuildExpressionInfo RebuildExpression(Net.Vpc.Upa.ExpressionFormula persistFormula)
 {
     Net.Vpc.Upa.Expressions.Expression e = ((Net.Vpc.Upa.ExpressionFormula)persistFormula).GetExpression();
     Net.Vpc.Upa.Impl.Persistence.RebuildExpressionInfo rr = new Net.Vpc.Upa.Impl.Persistence.RebuildExpressionInfo();
     rr.initialFormula = ((Net.Vpc.Upa.ExpressionFormula)persistFormula);
     Net.Vpc.Upa.Expressions.Expression e0 = e;
     Net.Vpc.Upa.Persistence.ExpressionCompilerConfig config = new Net.Vpc.Upa.Persistence.ExpressionCompilerConfig();
     config.SetExpandEntityFilter(false);
     //this is needed not to fire "this" alias usage exception
     config.SetThisAlias("this");
     config.BindAliastoEntity("this", field.GetEntity().GetName());
     Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression ce = null;
     Net.Vpc.Upa.ExpressionManager expressionManager = field.GetEntity().GetPersistenceUnit().GetExpressionManager();
     try {
         ce = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression)expressionManager.CompileExpression(e, config);
     } catch (System.ArgumentException ex) {
         if ((ex).Message.StartsWith("No enclosing Select found for"))
         {
             Net.Vpc.Upa.Expressions.Select ss = new Net.Vpc.Upa.Expressions.Select();
             ss.Field(e).From(field.GetEntity().GetName(), "this2");
             Net.Vpc.Upa.Expressions.Expression w = null;
             foreach (Net.Vpc.Upa.Field primaryField in field.GetEntity().GetPrimaryFields())
             {
                 Net.Vpc.Upa.Expressions.Expression pfe = new Net.Vpc.Upa.Expressions.Equals(new Net.Vpc.Upa.Expressions.UserExpression("this." + primaryField.GetName()), new Net.Vpc.Upa.Expressions.UserExpression("this2." + primaryField.GetName()));
                 if (w == null)
                 {
                     w = pfe;
                 }
                 else
                 {
                     w = new Net.Vpc.Upa.Expressions.And(w, pfe);
                 }
             }
             Net.Vpc.Upa.Impl.Uql.Util.UQLUtils.ReplaceThisVar(ss, "this2", expressionManager);
             ss.Where(w);
             e = ss;
         }
         else
         {
             throw ex;
         }
     }
     //throw new IllegalArgumentException("No enclosing Select found for " + v)
     if (ce == null)
     {
         ce = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression)expressionManager.CompileExpression(e, config);
         rr.compiledExpression = ce;
         rr.rebuiltFormula     = (new Net.Vpc.Upa.ExpressionFormula(e));
     }
     else
     {
         rr.compiledExpression = ce;
     }
     rr.expression = e;
     return(rr);
 }