Business Object does not show properties (fields)

Hi there!

I'm evaluating FastReport .NET Trial 1.1. Congratulations on this AWESOME product!! I've been using FastReport for Delphi for quite some time and after switching to .NET I really missed the best reporting engine on the market !!! I'm so glad I have my "good old" FastReport back in the .NET world :-)

Before I purchase I need to solve one big problem I'm currently having:

My application relies heavily on business objects, so I need to add those as datasources. But when I add my BO and open up FR designer, I only see the datasource (table) in the tree, but no fields (as if FastReport didn't see any properties of my BO). On a sidenote: All propeties are marked public, so that can't be the problem.

In the FR code window I can access the properties of my BO, but the code completion doesn't work on them.

Do you have any idea what could be the cause of this problem?

Thanks in advance!
Marco

Comments

  • edited 6:32AM
    Hello,

    Please check this post:
    http://www.fast-report.com/en/forum/?p=/discussion/5695

    BO fields are not supported, you should use properties instead.
  • edited June 2009
    AlexTZ wrote: »
    Hello,

    Please check this post:
    http://www.fast-report.com/en/forum/?p=/discussion/5695

    BO fields are not supported, you should use properties instead.

    Hi Alex. I know... but I do have properties! No fields.... (sorry for the confusion: In my first post I only used the term "field" to make an analogy to the DB world).

    I have properties exactly like described in your article. In the meantime I tried creating a new BO object of my type in FR script. From there I get code completion to see my properties. But the data tree will not display them...

    Any more ideas?

    Thanks!
    Marco

    PS: I should note that I derive my classes from a persistence framework. Maybe you know it: DevExpress.Xpo. I have added all necessary base assemblies to the FReport.ReferencedAssemblies property.
  • edited 6:32AM
    Marco,

    I'm not familiar with DevExpress Xpo. Here is how you can check your business objects:
          string propNames = "";
          using (BindingSource src = new BindingSource())
          {
            src.DataSource = FBusinessObject;  // <------------ put your business object here
            PropertyDescriptorCollection props = src.GetItemProperties(null);
            foreach (PropertyDescriptor prop in props)
            {
              propNames += prop.Name + "\r\n";
            }
          }
          MessageBox.Show(propNames);
    

    The latest version of FR.Net (1.1.20 and later) uses the same method when discovering the object's structure.
  • edited 6:32AM
    AlexTZ wrote: »
    Marco,

    I'm not familiar with DevExpress Xpo. Here is how you can check your business objects:
          string propNames = "";
          using (BindingSource src = new BindingSource())
          {
            src.DataSource = FBusinessObject;  // <------------ put your business object here
            PropertyDescriptorCollection props = src.GetItemProperties(null);
            foreach (PropertyDescriptor prop in props)
            {
              propNames += prop.Name + "\r\n";
            }
          }
          MessageBox.Show(propNames);
    

    The latest version of FR.Net (1.1.20 and later) uses the same method when discovering the object's structure.

    Hi Alex.

    Thanks for the code snippet. I ran it on my BO and it returned all the properties correctly... very strange.... they just won't show up in the designer.

    I'll play around some more. Let me know if you can think of any other thing to try.

    Regards
    Marco
  • edited 6:32AM
    The problem may be that FR uses type of object instead of object itself:

    src.DataSource = your_business_object.GetType();

    It works in most cases, but in your case it may fail. I will fix this in the next daily build (it will be ready in three hours).
  • edited 6:32AM
    AlexTZ wrote: »
    The problem may be that FR uses type of object instead of object itself:

    src.DataSource = your_business_object.GetType();

    It works in most cases, but in your case it may fail. I will fix this in the next daily build (it will be ready in three hours).

    Hi Alex! You're right, I get no properties when I use the code line from your last post.

    Thank you so much for making a new build. Looking forward to it.

    Regards

    Marco
  • edited 6:32AM
    Hi Alex

    I downloaded and installed the new build. Now FR sees the property! Thank you!!!!

    I just have one last problem: While FR sees 1:n (subcollections) perfectly, it does not seem to recognize 1:1 references. In the attached screenshot you'll see that my "Party" object has a subcollection of Addresses, which is correct. But the sub-object "Language" does not display any real properties. But in reality it contains properties like "Name" etc.

    So right now I can't have a report displaying [Contact.Language.Name]; FR fails with the message: "The name 'Contact' does not exist in the current context"

    Do I need to add some attribute to resolve the properties of single sub-objects? Or do you know what else could be the problem?

    Thanks again!

    Marco
  • edited 6:32AM
    Hi Marco,

    Could you show me the structure of your classes? I'm interested in "Language" and "Addresses" classes.
  • edited 6:32AM
    AlexTZ wrote: »
    Hi Marco,

    Could you show me the structure of your classes? I'm interested in "Language" and "Addresses" classes.
    Hi Alex.. no problem, I have attached the classes in this post. You probably need a few explanations:

    - My system is designed to be customizable for end customers. That's why I usually have an abstrace base class and an empty concrete class derived from it (CustParty --> Party, etc.)
    - The base class "BaseObject" is part of the XAF framework (persistence) by DevExpress.
    - XPCollection is an IEnumerable by the XAF framework which queries the DB and delivers all necessary objects from the DB store.
    - All those calls to "SetPropertyValue" (and similar) basically just tell the XAF framework to do something (e.g. notify the UI of changes etc.)

    If you have any other questions just ask!

    Regards
    Marco
  • edited June 2009
    PS: I'm sorry if I'm causing you a lot of work. But if we get this to work I'll write a general FR reporting adapter for the XAF framework. The integrated reporting engine of DevExpress is very weak and a lot of developers using XAF are seeking alternatives. So if we get it to work properly this may even provide you with more customers :-)
  • edited 6:32AM
    No problem, Marco [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> It will help me to improve FastReport a lot. Seems that the problem is that FR uses "live" object at the first level, but at the second level it uses Type to discover structure. Another thing that confusing me is that "Addresses" has a lot of duplicate columns (3 x Owner, 3 x Country).[/img]
  • edited 6:32AM
    AlexTZ wrote: »
    No problem, Marco [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> It will help me to improve FastReport a lot. Seems that the problem is that FR uses "live" object at the first level, but at the second level it uses Type to discover structure. Another thing that confusing me is that "Addresses" has a lot of duplicate columns (3 x Owner, 3 x Country).[/img]

    Would it help you if I created an isolated sample application to re-create the problem? You'd probably have to install a trial version of the corresponding DevExpress components. I could direct you to the download link for that also.

    Let me know.

    Regards
    Marco
  • edited 6:32AM
    Hi Alex

    I created a very small sample application which reproduces the problem. I think you don't even have to download the DevExpress stuff since the DLL's are included. If it doesn't work you need to download and install DXperience-9.1.4.exe from:
    http://www.devexpress.com/Downloads/NET/

    Kind regards!

    Marco
  • edited 6:32AM
    Many thanks!

    I will inspect the test project and let you know when I fix the problem.
  • edited 6:32AM
    Problem solved (I hope [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> The new version will be available in three hours. Another improvement I made to filter some service properties which Xpo generates. To do this, use the following code:[/img]
            Config.ReportSettings.FilterBusinessObjectProperties += new FilterPropertiesEventHandler(ReportSettings_FilterBusinessObjectProperties);
    
            void ReportSettings_FilterBusinessObjectProperties(object sender, FilterPropertiesEventArgs e)
            {
              if (e.Property.Name.Contains("!") || e.Property.Name == "This" || e.Property.Name == "Oid")
                e.Skip = true;
            }
    
  • edited June 2009
    AlexTZ wrote: »
    Problem solved (I hope [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> The new version will be available in three hours. Another improvement I made to filter some service properties which Xpo generates. To do this, use the following code:[/img]
            Config.ReportSettings.FilterBusinessObjectProperties += new FilterPropertiesEventHandler(ReportSettings_FilterBusinessObjectProperties);
    
            void ReportSettings_FilterBusinessObjectProperties(object sender, FilterPropertiesEventArgs e)
            {
              if (e.Property.Name.Contains("!") || e.Property.Name == "This" || e.Property.Name == "Oid")
                e.Skip = true;
            }
    

    Hi Alex! Thanks so much!! I see that you posted a new version on your main website (dated June 19). I downloaded and installed it, but the changes you mentioned above don't exist. Maybe I just tried too early!?

    Have a great weekend! And thanks for your excellent support! I'll let you know my results as soon as I get to test the latest updates.

    Marco
  • edited 6:32AM
    Strange, the 1.1.25 version (which is available for download now) must have necessary changes.
  • edited 6:32AM
    Sorry, that was my mistake! For some reason firefox had cached the previous version and just kept "downloading" that one. Everything works perfectly now!!! I even tested a property of type "Image" and it works like a charm!

    So this weekend I can get started on my XAF module for FastReport integration! Awesome!

    Thanky you so much again!

    Regards
    Marco

    PS: If I purchase the WinForms/WebForms version of FR.NET, will I be able to upgrade to Professional for the price difference later on?
  • edited 6:32AM
    wrote:
    PS: If I purchase the WinForms/WebForms version of FR.NET, will I be able to upgrade to Professional for the price difference later on?

    Sure. You can start with WinForms and upgrade if necessary.

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.