public void InterpreteScript6Test() { var log = new BdoLog(); var scriptVariableSet = BdoScript.CreateVariableSet(); var resultScript = GlobalVariables.Scope.Interpreter.Evaluate <string>( _script6, default, scriptVariableSet, log)?.ToString();
/// <summary> /// Adds the specified sub query. /// </summary> /// <param name="subQuery">The sub query to consider.</param> /// <returns>Return this added parameter.</returns> public DataExpression UseSubQuery(IDbQuery subQuery) { if (SubQueries == null) SubQueries = new List<DbQuery>(); SubQueries.Add((DbQuery)subQuery); return BdoScript.Function("sqlQuery", SubQueries.Count.ToString()).CreateExp(); }
/// <summary> /// /// </summary> /// <param name="obj"></param> /// <returns></returns> internal static object AsSqlValue(this object obj) { if (obj == null) { return(Null()); } else if (obj is string text) { return(BdoScript.Function("sqlText", text)); } else if (obj is DbField field) { return((field?.ToScript()).CreateExpAsScript()); } else if (obj is DbTable table) { return((table?.ToScript()).CreateExpAsScript()); } else if (obj is IScalarElement param) { return(param.AsExp()); } else if (obj is DataExpression || obj is BdoScriptword) { return(obj); } else if (obj.GetType().IsNumeric()) { return(obj); } return(obj?.ToString(DataValueTypes.Any, true)); }
public void InterpreteScript1Test() { var log = new BdoLog(); var scriptVariableSet = BdoScript.CreateVariableSet(); var resultScript = GlobalVariables.Scope.Interpreter.Evaluate <bool?>(_script1, DataExpressionKind.Script, scriptVariableSet, log)?.ToString(); string xml = string.Empty; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml() + "'"; } Assert.That(_interpretedScript1.Equals(resultScript, StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml); }
public void InterpreteScriptNullTest() { var log = new BdoLog(); var scriptVariableSet = BdoScript.CreateVariableSet(); var resultScript = GlobalVariables.Scope.Interpreter.Evaluate <bool?>(null as DataExpression, scriptVariableSet, log)?.ToString(); string xml = string.Empty; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml() + "'"; } Assert.That(resultScript == null, "Bad script interpretation" + xml); }
/// <summary> /// Gets the Sql value of the specified object. /// </summary> /// <param name="value">The value to consider.</param> public static DataExpression Value(object value) => BdoScript.Function("sqlValue", value).CreateExp();
/// <summary> /// Creates a BDO script representing a text. /// </summary> /// <param name="param1">The parameter to consider.</param> public static DataExpression Text(object param1) => BdoScript.Function("sqlText", param1).CreateExp();
/// <summary> /// Converts this instance as a word. /// </summary> /// <param name="element">The parameter to consider.</param> public static DataExpression AsExp(this IScalarElement parameter) { return(BdoScript.Function("sqlParameter", parameter?.Name ?? parameter.Index.ToString()) .CreateExp()); }
/// <summary> /// /// </summary> /// <param name="obj"></param> /// <param name="parameters"></param> /// <returns></returns> internal static BdoScriptword DbFunction(string name, params object[] parameters) { return(BdoScript.Function(name, parameters.Select(p => p.AsSqlValue()).ToArray())); }