Click or drag to resize

BcfColumnSetupTFormatter Property

[This is preliminary documentation and is subject to change.]

Gets or sets the format function.

Namespace:  CalculationWorks.BusinessModel.Design
Assembly:  CalculationWorks.BusinessModel (in CalculationWorks.BusinessModel.dll) Version: 4.0.0-beta7
Syntax
public BcfFormat<T> Formatter { get; set; }

Return Value

Type: BcfFormatT
The format function if set; otherwise null.
Examples
Add Trimming to all String Columns
public static class SetupHelper 
{
    public static void AddStringTrimming(BcfDataSetSetup setup) 
    {
        foreach(var stringColumnSetup in setup.Tables.Where(t => t.Columns != null).SelectMany(t => t.Columns).OfType<BcfColumnSetup<string>>()) 
        {
            if(!stringColumnSetup.HasFormatter) stringColumnSetup.Formatter = StringColumnFormatter;
        }
    }
    private static string StringColumnFormatter(BcfColumn<string> column, string proposedValue) 
    {
        var s = proposedValue?.Trim();
        if(column.AllowNull && s == string.Empty) return null;
        return s;
    }
}
See Also