Example #1
0
        public void Values(params object[] Values)
        {
            if (Values.Length != this._columns.Count)
            {
                throw new Exception("Number of values does not match the number of columns. Make sure columns are specified before values are added.");
            }

            this._values.Clear();
            foreach (object value in Values)
            {
                string valueasstring = string.Empty;

                if (value != null)
                {
                    valueasstring = value.ToString();

                    #region BOOLEAN
                    if (value.GetType().Name.ToLower() == "boolean")
                    {
                        if (valueasstring.ToLower() == "true")
                        {
                            valueasstring = "1";
                        }
                        else
                        {
                            valueasstring = "0";
                        }
                    }
                    #endregion

                    #region ENUM
                    if (value.GetType().BaseType.Name.ToLower() == "enum")
                    {
                        valueasstring = ((int)value).ToString();
                    }
                    #endregion

                    #region DECIMAL
                    if (value.GetType().Name.ToLower() == "decimal")
                    {
                        valueasstring = value.ToString().Replace(",", ".");
                    }
                    #endregion

                    #region LIST
                    if (value.GetType().Name.ToLower() == "list`1")
                    {
                        valueasstring = SNDK.Serializer.SerializeObjectToString(value);
                    }

                    #endregion
                }

                this._values.Add(QueryBuilder.MakeSafe(valueasstring));
            }
        }
Example #2
0
 public void OrderBy(string Column, QueryBuilderOrder Order)
 {
     if (Order == QueryBuilderOrder.Accending)
     {
         this._orderby = "ORDER BY '" + QueryBuilder.MakeSafe(Column) + "' ASC";
     }
     else if (Order == QueryBuilderOrder.Decending)
     {
         this._orderby = "ORDER BY '" + QueryBuilder.MakeSafe(Column) + "' DESC";
     }
 }
Example #3
0
        public void AddWhere(string Column, string Expression, object Value)
        {
            string valueasstring = string.Empty;

            if (Value != null)
            {
                valueasstring = Value.ToString();

                #region BOOLEAN
                if (Value.GetType().Name.ToLower() == "boolean")
                {
                    if (valueasstring.ToLower() == "true")
                    {
                        valueasstring = "1";
                    }
                    else
                    {
                        valueasstring = "0";
                    }
                }
                #endregion

                #region ENUM
                if (Value.GetType().BaseType.Name.ToLower() == "enum")
                {
                    valueasstring = ((int)Value).ToString();
                }
                #endregion

                #region DECIMAL
                if (Value.GetType().Name.ToLower() == "decimal")
                {
                    valueasstring = Value.ToString().Replace(",", ".");
                }
                #endregion
            }

            this._wheres.Add("(" + Column + " " + Expression + " '" + QueryBuilder.MakeSafe(valueasstring) + "')");
        }