private RowObjectAdapter Bind(Selector columnNames) { foreach (PropertyInfo propertyInfo in Reflex.GetColumnProperties(obj)) { ColumnAttribute attribute = Reflex.GetColumnAttribute(propertyInfo); if (attribute != null && this.Row.Table.Columns.Contains(attribute.ColumnNameSaved)) { DataField field = this.fields.Add(attribute.ColumnNameSaved, attribute.Type); ColumnAdapter column = new ColumnAdapter(field); this.Bind(column); column.Field.Identity = attribute.Identity; column.Field.Primary = attribute.Primary; if (attribute.Identity || attribute.Computed || ! columnNames.Exists(attribute.ColumnNameSaved)) column.Field.Saved = false; else column.Field.Saved = attribute.Saved; } } //in case of ColumnAttribute not setup Identity and Primary Keys fields.UpdatePrimaryIdentity(obj.Primary, obj.Identity); return this; }
public RowObjectAdapter(PersistentObject obj, Selector columnNames) : base(obj.TableName, obj.Locator, obj.NewRow) { this.obj = obj; this.transaction = obj.Transaction; Bind(columnNames); }