DoddleReport icon indicating copy to clipboard operation
DoddleReport copied to clipboard

Fluent API for working with data types

Open jzabroski opened this issue 6 years ago • 0 comments

I would like code to work more like this:

public class ProductReport : Report<Product>
{
    ProductReport()
    {
        DataField(x => x.UnitPrice) // this automatically infers it is a number,
        // and automatically applies DataStyle.HorizontalAlignment = HorizontalAlignment.Right
           .WithHeader(x => x.Text.Replace("Unit",string.Empty)) // remove "Unit" from "UnitPrice"
           .WithData(x => {
               x.AsMoney(); // automatically applies horizontalalignment.right and DataFormatString = "{0:C"}
               x.Style.HorizontalAlignment = HorizontalAlignment.Right; // again, less typing
           })
           .BuildIt(); // converts Expression tree to Report instance variables
    }
}

jzabroski avatar Oct 16 '18 01:10 jzabroski