Ejemplo n.º 1
0
        /// <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();
        }
Ejemplo n.º 2
0
        /// <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));
        }
 /// <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();
Ejemplo n.º 5
0
 /// <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());
 }
Ejemplo n.º 6
0
 /// <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()));
 }