Click or drag to resize

BcfColumnSetupTFormatter Property

Gets or sets the format function.

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

Return Value

Type: BcfFormatT
The format function if set; otherwise .
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