/// <summary> /// Returns a value for this column when given a row. /// </summary> public object GetValue(IVariantTableRow <object> row) //(note: this method is the master method for getting values, due to calculated columns that may not be on the entity object) { var result = ValueHandler != null?ValueHandler((ITableRow <TEntity>) row, this) : DBNull.Value; //? /*Entity.Property{get} can also be used for a value handler!*/ if (IsCalculated) return result; // (always return this if this is a calculated-only column) if (result != DBNull.Value) { return(result); // (user can override entity values, such as might be required for translations) } var property = Table.GetEntityPropertyFromCache(row.EntityType, PropertyName); return(property?.GetValue(row.Entity, null)); // (if no user handler exists [override/filter], or it's return is null, get the value from the row) }
public T GetValue <T>(IVariantTableRow <object> row) { return(Types.ChangeType <T>(GetValue(row))); }