internal Expression(string arg) : base(null) { Build = (buildContext, buildArgs) => { QueryTalkException exception; var variable = buildContext.TryGetVariable(arg, out exception); if (variable.IsInliner()) { if (variable.DT != DT.InExpression) { buildContext.TryTakeException(variable.DT.InvalidInlinerException(GetType().Name, variable.Name, _inliners)); return(null); } string arg2 = variable.Name; if (buildArgs.Executable != null) { ParameterArgument argument = buildArgs.Executable.GetInlinerArgument(arg2); if (argument.Value != null) { arg2 = argument.Build(buildContext, buildArgs); } else { buildContext.TryTakeException(new QueryTalkException(this, QueryTalkExceptionType.InlinerArgumentNull, String.Format("{0} = null", arg2))); return(null); } } return(arg2.ToString()); } else if (variable.IsConcatenator()) { buildContext.TryTakeException(InvalidConcatenationException(variable.Name)); return(null); } // non-existing variable or expression string else { // note: non-existing variable will pass the test => the server will throw an error CheckExpressionString(arg); return(arg); } }; }
internal Table(System.String arg) : base(arg) { SetArgType(arg); Build = (buildContext, buildArgs) => { string sql; Variable variable = TryGetVariable(buildContext); if (variable.IsInliner()) { string arg2 = variable.Name; if (variable.DT != DT.InTable) { buildContext.TryTakeException(variable.DT.InvalidInlinerException(GetType().Name, arg2, _inliners)); return(null); } if (buildArgs.Executable != null) { // get param argument ParameterArgument argument = buildArgs.Executable.GetInlinerArgument(arg2); if (argument.Value != null) { if (argument.Value is System.String) { arg2 = Filter.DelimitTableMultiPart((string)argument.Value, out chainException); } else if (argument.Value is View) { arg2 = Filter.Enclose(arg2); } else { arg2 = argument.Build(buildContext, buildArgs); } } else { buildContext.TryTakeException(new QueryTalkException(this, QueryTalkExceptionType.InlinerArgumentNull, String.Format("{0} = null", arg2))); return(null); } } return(arg2); } else { if (ProcessVariable(buildContext, buildArgs, out sql, variable)) { return(sql); } // specific (existing) variable checks if (variable != null && variable.VariableType.IsParamOrSqlVariable()) { // variable should be a table if (!variable.DT.IsTable()) { buildContext.TryTakeException(CreateException(QueryTalkExceptionType.TableVariableMissing, arg)); return(null); } // check concatenation with non-udt table variable (NOT ALLOWED) if (buildContext.Current.Query.Master.IsConcatenated) { if (variable.NameType == null) { buildContext.TryTakeException(CreateException(QueryTalkExceptionType.TableVariableDisallowed, arg)); return(null); } } } } // default sql = Filter.DelimitMultiPartOrParam(arg, IdentifierType.Table, out chainException); buildContext.TryTakeException(chainException); return(sql); }; }