public SQLSchemaData(string newColumnName, string newColumnValue)//SQLTypes newColumnType)
            {

                ColumnType  = SQLTypes.E_bigint;
                ColumnName  = newColumnName;
                ColumnValue = newColumnValue;

                // logic to match the string to value
                if (Regex.IsMatch(newColumnValue, @"^\d+$"))
                {
                    // This is a bigint or int, but use bigger data type
                    // Assume bigint may help us avoid data size issues.
                    ColumnType  = SQLTypes.E_bigint;
                    ColumnValue = newColumnValue;
                }
                //else if (Regex.IsMatch(newColumnValue, @"""\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d\.\d*"""))
                //{
                //    // This is a datetime
                //    ColumnType  = SQLTypes.E_datetime;
                //    ColumnValue = newColumnValue.Substring(1, newColumnValue.LastIndexOf("\"") - 1);
                //}
                else if (Regex.IsMatch(newColumnValue, @""".*"""))
                {
                    // This is a string
                    ColumnType  = SQLTypes.E_nvarchar;
                    ColumnValue = "'" + newColumnValue.Substring(1, newColumnValue.LastIndexOf("\"") - 1) + "'";
                }
            }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sqlType"></param>
        /// <param name="properties"></param>
        /// <param name="model"></param>
        /// <returns></returns>

        /*private string GetSqlCommandText(SQLTypes sqlType, ICollection<PropertyInfo> properties = null, T model = null)
         * {
         *  string sqlCommandText = String.Empty;
         *  switch (sqlType)
         *  {
         *      case SQLTypes.Insert:
         *          sqlCommandText = GetPropertyStringForInsert(properties);
         *          break;
         *      case SQLTypes.Update:
         *          sqlCommandText = this.GetPropertyStringForUpdate(properties, model.IDName);
         *          break;
         *      case SQLTypes.Delete:
         *          sqlCommandText = this.GetPropertyStringForDelete(GetPrimaryKeyProperties(model));
         *          break;
         *      case SQLTypes.SelectAll:
         *          sqlCommandText = this.GetPropertyStringForGetAll();
         *          break;
         *      case SQLTypes.GetById:
         *          sqlCommandText = this.GetPropertyStringForGetByID(model.IDName);
         *          break;
         *  }
         *  return sqlCommandText;
         * }*/

        private string GetSqlCommandText(SQLTypes sqlType, ICollection <PropertyInfo> properties = null, IBaseModel model = null)
        {
            string sqlCommandText = String.Empty;

            switch (sqlType)
            {
            case SQLTypes.Insert:
                sqlCommandText = GetPropertyStringForInsert(properties);
                break;

            case SQLTypes.Update:
                sqlCommandText = this.GetPropertyStringForUpdate(properties, model.IDName);
                break;

            case SQLTypes.Delete:
                sqlCommandText = this.GetPropertyStringForDelete(GetPrimaryKeyProperties(model));
                break;

            case SQLTypes.SelectAll:
                sqlCommandText = this.GetPropertyStringForGetAll();
                break;

            case SQLTypes.GetById:
                sqlCommandText = this.GetPropertyStringForGetByID(model.IDName);
                break;
            }
            return(sqlCommandText);
        }
 public SQLSchemaData()
 {
     ColumnName  = "";
     ColumnValue = "";
     ColumnType  = SQLTypes.E_bigint;
 }