public TableColumn(FieldAttribute definition, PropertyFieldInfo member) { Name = definition.Name; IsNullable = definition.IsNullable; PrimaryKey = definition.PrimaryKey; AutoIncrement = definition.AutoIncrement; Type = member.Type; _member = member; if (definition is ForeignKeyAttribute) { ParentTableType = ((ForeignKeyAttribute)definition).ForeignTableType; IsForeignKey = true; } FieldName = member.Name; Get = (tc, inst) => _member.GetValue(inst); Set = (tc, inst, val) => _member.SetValue(inst, val); if (Type.IsEnum) { Get = (tc, inst) => (int)_member.GetValue(inst); } if (Type == typeof(decimal)) { Set = (tc, inst, val) => _member.SetValue(inst, Convert.ToDecimal(val)); } }
public TableColumn(TableColumn tc) { _member = tc._member; PrimaryKey = tc.PrimaryKey; AutoIncrement = tc.AutoIncrement; FieldName = tc.FieldName; IsNullable = tc.IsNullable; IsForeignKey = tc.IsForeignKey; ParentTableType = tc.ParentTableType; RawName = tc.RawName; Type = tc.Type; Get = tc.Get; Set = tc.Set; }