Datasource Text = "[reportData.Description]" vs "[reportData.ConfigStatusComponent.Description]",

Using TextObject() and RegisterData All code works well until I change the following:

The following works when I do my report....  

Text = "[reportData.Description]" ;

I need to add the following.... is this the proper syntax? I get an error on report.Prepare();

Text = "[reportData.ConfigStatusComponent.Description]" ;

 //Get data source

      var configStatusComponentApplicationID = await ConfigStatusComponentController.GetDescriptionID(_context, ModelName.Application.Value);

      var configStatusComponentContractID = await ConfigStatusComponentController.GetDescriptionID(_context, ModelName.Contract.Value);

      var ConfigStatusComponentTypeList = await _context.ConfigStatusComponentTypes.Where(w => w.ConfigStatusComponentID == configStatusComponentApplicationID || w.ConfigStatusComponentID == configStatusComponentContractID).Include(i => i.ConfigStatusComponent).OrderBy(o => o.ConfigStatusComponent.Description).ThenBy(o => o.DisplayOrder).ToListAsync();


      //Set Data Source

      var reportData = ConfigStatusComponentTypeList;

      report.RegisterData(reportData, "reportData");

      report.GetDataSource(reportDataName).Enabled = true;

....create a TextObject

      var result = new TextObject()

      {

        Bounds = new RectangleF(toLeft, toTop, toWidth, toHeight),

        //result.Bounds = new RectangleF(0, 0,Units.Centimeters * 10, Units.Centimeters * 0.5f);

        AutoWidth = true,

        Font = toFont,

        Text =  "[reportData.Description]",

        HorzAlign = HorzAlign.Left

        };

Comments

  • ConfigStatusComponent is 'business object'/'poco class' name, fastreport uses alias as reference name.

    Report.RegisterData(IEnumerable, string)

  • ok...I changed my code to

    .Select(s=> new { Description = s.ConfigStatusComponent.Description,Description2=s.Description}).ToListAsync();

    and that gets me a simple IEnumerable list

  • Hello!

    A sufficient `maxNestingLevel` has been passed to `report.RegisterData(...)` (the default is often 1, so the nested `ConfigStatusComponent` class is not expanded – set `maxNestingLevel` to 3 or higher!):

    report.RegisterData(data, ‘reportData’, maxNestingLevel: 3);

    The instance of the child property `ConfigStatusComponent` at the data level is not null without protection (or a null check is used in the expression/script), and the corresponding nested-level data source is included (when designing in .frx, it is visible as a child node within `reportData`)

This discussion has been closed.