public TableRelationDefinition(Type type, ColumnDefinition foreignKey, string primaryKey, string propertyName) : base(type) { ForeignKeyColumn = foreignKey; PrimaryKeyColumn = Columns.Single(i => i.ColumnName == primaryKey); PropertyName = propertyName; }
private ColumnDefinition GetColumnFromProperty(PropertyInfo property) { var key = property.GetCustomAttribute<KeyAttribute>(); var columnInfo = property.GetCustomAttribute<ColumnAttribute>(); var autoNumeric = property.GetCustomAttribute<AutoIncrementAttribute>(); var columnName = columnInfo != null ? columnInfo.Name : property.Name; var column = new ColumnDefinition() { ColumnName = columnName, FieldName = property.Name, IsKey = (key != null || (property.Name.Equals("Id") && property.PropertyType == typeof(int))), IsAutoIncrement = (autoNumeric != null) || (property.Name.Equals("Id") && property.PropertyType == typeof(int)) }; return column; }
public void AddColumn(ColumnDefinition column) { ((List<ColumnDefinition>)Columns).Add(column); }
public string GetQualifiedColumnName(ColumnDefinition column) { return "{0}{2}{1}.{0}{3}{1}".Fi(_dialectProvider.SystemNameStartCharacter, _dialectProvider.SystemNameEndCharacter, column.Table.TableName, column.ColumnName); }
public object GetColumnValue(object model, ColumnDefinition column) { return _objectAccesor.GetPropertyValue(model, column.FieldName); }
public string GetColumnSqlValue(object model, ColumnDefinition column) { return GetColumnValue(model, column).ToSql(); }
public string GetQualifiedColumnAndValue(ColumnDefinition column, object model) { return "{0} = {1}".Fi(GetQualifiedColumnName(column), GetColumnSqlValue(model, column)); }