Esempio n. 1
0
 /// <summary>
 /// Creates a CREATE command from the table class template. Uses the first int column as primary key.
 /// </summary>
 public BuiltCreateCommand()
 {
     _tableName = SqlTableHelper.GetTableName <T>();
     _columns   = SqlTableHelper.GetColumnAttributes <T>();
     if (_columns.Count == 0)
     {
         throw new Exception("Can't create empty table.");
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Creates a new value list using all columns from the table.
 /// </summary>
 public BuiltValueList()
 {
     _columnAttributes = SqlTableHelper.GetColumnAttributes <T>();
     foreach (var column in _columnAttributes)
     {
         _columnsWithValues.Add(new ColumnWithValue
         {
             Column    = column.ColumnName,
             Value     = "",
             ValueType = column.Type
         });
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Creates a new value list using the specified columns.
        /// </summary>
        public BuiltValueList(List <string> columns)
        {
            _columnAttributes = SqlTableHelper.GetColumnAttributes <T>();
            foreach (var col in columns)
            {
                SqlColumn columnAttribute = _columnAttributes.FirstOrDefault(attr => attr.ColumnName == col);
                if (columnAttribute == null)
                {
                    throw new Exception($"Table \"{typeof(T).FullName}\" does not contain a column named \"{col}\"");
                }

                _columnsWithValues.Add(new ColumnWithValue
                {
                    Column    = col,
                    Value     = "",
                    ValueType = columnAttribute.Type
                });
            }
        }