public BuiltInsertCommand <T> AddItem(T item) { var value = new BuiltValueList <T>(_columns); foreach (var p2c in SqlTableHelper.PropertiesToColumnNames <T>()) { if (!_columns.Contains(p2c.Value)) { continue; } value.AddValueFor(p2c.Value, p2c.Key.GetValue(item, null).ToString()); } return(this); }
/// <summary> /// Adds a row to this INSERT command by providing values for every column (in the correct order). /// This function does not allow you to surround the values with a specific character, though. /// </summary> /// <param name="orderedValues">The values to be inserted.</param> public BuiltInsertCommand <T> AddRow(params string[] orderedValues) { if (_columns == null) { throw new Exception("Use Into to initialise the table and columns before calling this function."); } if (orderedValues.Length != _columns.Count) { throw new Exception("Column count does not match amount of specified values."); } var row = new BuiltValueList <T>(_columns); for (int i = 0; i < orderedValues.Length; i++) { row.AddValueFor(_columns[i], orderedValues[i]); } _rowValues.Add(row); return(this); }
/// <summary> /// Add a row of values to this INSERT command. /// </summary> public BuiltInsertCommand <T> AddValues(BuiltValueList <T> values) { _rowValues.Add(values); return(this); }