public bool TryCreateColumn(IColumnSelector selector, out IColumnConfig column) { column = Factories.Column.Create(this, selector); if (!ColumnValidator.Validate(this.Config.Database, this, column)) { return(false); } column = this.Columns.AddOrUpdate(column.Identifier, column); this.Reset(); return(true); }
public IColumnConfig CreateColumn(IColumnSelector selector) { var column = Factories.Column.Create(this, selector); if (!ColumnValidator.Validate(this.Config.Database, this, column)) { throw new InvalidOperationException(string.Format("Table has invalid configuration: {0}", column)); } column = this.Columns.AddOrUpdate(column.Identifier, column); this.Reset(); return(column); }
public IEnumerable <IColumnConfig> GetColumns(IDatabase database, ITableConfig table, ITransactionSource transaction = null) { var properties = new EntityPropertyEnumerator(table.TableType); var columns = new List <IColumnConfig>(); foreach (var property in properties) { if (!ColumnValidator.Validate(database, property)) { continue; } var column = Factories.Column.Create(table, ColumnConfig.By(property)); if (!ColumnValidator.Validate(database, table, column, transaction)) { continue; } columns.Add(column); } return(columns); }
public static bool Validate(IDatabase database, bool strict, IEnumerable <IRelationConfig> relations, ITransactionSource transaction = null) { foreach (var relation in relations) { if (relation == null) { if (strict) { return(false); } else { continue; } } if (string.IsNullOrEmpty(relation.Identifier)) { return(false); } var columns = relation.Expression .Flatten <IColumnBuilder>() .ToArray(); if (strict && columns.Length < 2) { //We need at least a left and right column for the relation to be valid. return(false); } foreach (var column in columns) { if (!ColumnValidator.Validate(database, column.Column.Table, column.Column, transaction)) { return(false); } } } return(true); }