Changes in business objects engine

edited 2:52PM in FastReport .NET
Hello everybody,

The new build (1.1.20) comes with completely new engline that handles business objects (BO). The new engine was designed to overcome the following restrictions of old engine:

- when registering a business object, you have to indicate maximum nesting level. It was needed because not all BOs have tree-like structure, some of them use parent-child relations, which may lead to infinite loop. This is no longer needed with the new engine: you may have as many nested objects as you want - just go "Data|Choose Report Data..." dialog and expand elements that you want to use;

- old BO engine was not able to correctly represent nested IEnumerable elements if they were contained in another (non-IEnumerable type) properties. For example, consider the following class structure:
public class Master
{
  public DetailInfo Info { get; set; }
}

public class DetailInfo
{
  public List<Detail> Detail { get; set; }
}

public class Detail
{
  public int SomeProperty { get; set; }
}

in the old version, this was converted to the following data tree:
Master
|
+- Info
|
+- Detail

(i.e. the Detail datasource belongs to Master which is confusing)

The new version handles this more natural:
Master
|
+- Info
   |
   +- Detail

Unfortunately, this is a breaking change. Here is a list of issues that should be corrected:

1) The
report.RegisterData(IEnumerable, string, BOConverterFlags, int)
method is kept for compatibility only. Instead of it, use
report.RegisterData(IEnumerable, string)
-or-
report.RegisterData(IEnumerable, string, int)
The latter method creates n-level initial datasource structure and may be used if you create a report in code. In other cases, use the first method.

2) New BO engine can handle public properties only. Fields cannot be handled anymore. If you have a code like
public MyClass
{
  public string MyField;
}
you need to convert the field to a property:
public MyClass
{
  private string _myField;

  public string MyField
  {
    get { return _myField; }
    set { _myField = value; }
  }
}


3) New BO engine handles nested IEnumerable properties differently, as stated above. Due to this new behavior, you have to change your reports (that use nested business objects) accordingly:
- open the report in FR designer;
- go "Data|Choose Report Data..." window and uncheck the root element (in the sample above - the "Master"). Close the dialog;
- save the report;
- open the report again;
- go "Data|Choose Report Data..." window and check datasources you need;

The steps above are needed to delete old (bad) data objects that is stored in the report file, and create new ones. Now attach new data objects to report items:
- assign appropriate datasources to each databand in your report (double-click the databand and select datasource). If you use the "Matrix" object, check its "DataSource" property as well;
- you may also need to change Text objects. In the sample class above, to access the Detail.SomeProperty, you have to use its full path: "Master.Info.Detail.SomeProperty". In earlier version, the path was: "Master.Detail.SomeProperty" - you have to correct this.

Comments

  • edited 2:52PM
    Thanks for telling us about it. It's very useful information.

    Regards,
    Louise
    Pret travaux
  • edited 2:52PM
    I have applied these codes but these are giving some errors in my system. Can u help?

    Thanks
  • edited 2:52PM
    ublic class Master
    {
    public DetailInfo Info { get; set; }
    }

    public class DetailInfo
    {
    public List<Detail> Detail { get; set; }
    }

    public class Detail
    {
    public int SomeProperty { get; set; }

    Unfortunately, this coding set is not working in mine.

    peace out~
  • cbr00tcbr00t Izmir, Turkiye
    edited 2:52PM
    I was use [Browsable()] attribute on DataSource Properties. There are some properties that Report must not see.
    (e.g: Some properties has a value as DELEGATE... If report check these properties, it throws an exception when I execute 'RegisterData').

    So, Will I cannot say that, only see properties that have [Browsable(true)] attribute??
  • edited 2:52PM
    Thanks for sharing this detailed information regarding new engline, codes shared by you really worked for me, i am glad to use this codes for my engline. But as you said after replacing codes we come across those following errors mentioned by you ,your explanation really helped us in overcoming those obstacles.Will try to experiment with this piece of code and if found any strange behavior will share it here for the discussion.Great post thanks once again.
  • edited November 2011
    Thanks for posting this code for us, it will definitely come in handy, I'm going to try it out.

    May

    hairmax lasercomb review rogaine side effects .
  • edited November 2011
    mayle wrote: »
    Thanks for posting this code for us, it will definitely come in handy, I'm going to try it out.

    May
    Regrow hair with hairmax lasercomb review rogaine side effects .



    No doubt, have you tried this out yet? I couldn't get it to work. I must be missing something as I am getting some error messages.

    Ragards, B
  • edited November 2011
    cbr00t wrote: »
    I was use [Browsable()] attribute on DataSource Properties. There are some properties that Report must not see.
    (e.g: Some properties has a value as DELEGATE... If report check these properties, it throws an exception when I execute 'RegisterData').
    Regrow hair with biotin side effects rogaine foam rogaine for women reviews
    So, Will I cannot say that, only see properties that have [Browsable(true)] attribute??

    I was wondering the same....... Anyone have an answer?
  • wrote:
    3) New BO engine handles nested IEnumerable properties differently, as stated above. Due to this new behavior, you have to change your reports (that use nested business objects) accordingly:
    - open the report in FR designer;
    - go "Data|Choose Report Data..." validador window and uncheck the root element (in the sample above - the "Master"). Close the dialog;
    - save the report;
    - open the report again;
    - go "Data|Choose Report Data..." window and check datasources you need;

    I have the same problem and I can't fix it.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.