Problem with 1:1 subobject in business objects datasource

Hi Alex

I've already made a huge step forward in integrating FastReport with XAF. The module is in beta stage. I'm waiting for DevExpress to fix a few bugs in their framework.

Meanwhile I discovered another bug in FR. Handling of 1:1 sub-objects is not quite correct yet. Here's how to reproduce it:

1. Open my sample project (update references to FastReport)
2. Note that I have two address objects: One pointing to Country "Switzerland" and one to "Germany"
3. Run the example
4. Open the "TestReport" and preview it: You'll see that BOTH address lines display "Switzerland" as their country, which is incorrect (the second one should be "Germany")
5. Now open "TestReportWithSorting" and try to preview it: You get an error message. The only difference in this report is that I tried to sort the "Addresses" collection by the subproperty "Country.Name".

Remark: When you're working on the sorting/displaying of sub-properties, please also consider that 1:1 subobjects could be "null". I suppose that in this case FR should just display "string.empty" for strings, zero for numbers, "nothing" for dates, etc. I didn't try this yet, so maybe you've already implemented this.

Last but not least I have a "wish": Do you think it is possible for you to add support for the "Guid" type? It would be sufficient for me if you treated it as a string (using the ToString() method). The reason is simple: If I ever want to do a master-detail on two collections of objects, the Guid would be the key property to connect them in FR.

Wow, that's a lot.

Thank you so much in advance!
Regards
Marco

Comments

  • edited 6:47AM
    Hello Marco,

    Thanks for the test project.
    Due to some reason, XAF returns the Address.Country property type descriptor as IEnumerable. I think it is internal logic of XAF. But I cannot distinguish between 1:1 properties and lists. I think I will add another event that you will use to return correct property metadata.

    Regarding the GUID: it is possible now to get a column value of Guid type and convert it to string:
    [Table.GuidColumn].ToString()
  • edited 6:47AM
    I do some investigations and here is a result:
    When FR asks XAF to get property descriptors for the particular object, XAF returns own property descriptors, instead of real properties of your object. Looks like XAF descriptors are used to support internal logic. For example, if you want Address.Country property, you will get XAF descriptor telling you that it is XPCollection property (instead of property of "Country" type)! That's why you see Country element in the Data tree as a datasource, but in "real word" it is just a nested property.

    To solve this problem, I corrected the FilterProperties event handler so it will be able to replace the property descriptor returned by XAF with real property of your object. The fixed version will be available in 7 hours. Here is a code of new event handler:
            void ReportSettings_FilterBusinessObjectProperties(object sender, FilterPropertiesEventArgs e)
            {
                if (e.Property.Name.Contains("!") || e.Property.Name=="This" || e.Property.Name=="Oid")
                {
                    e.Skip = true;
                }
                if (e.Property.PropertyType == typeof(XPCollection))
                {
                  Type componentType = ListBindingHelper.GetListItemType(sender);
                  PropertyInfo propInfo = componentType.GetProperty(e.Property.Name);
                  e.Property = TypeDescriptor.CreateProperty(
                    componentType, 
                    e.Property.Name, 
                    propInfo.PropertyType, 
                    null);
                }
            }
    
  • edited 6:47AM
    Hi Alex!

    Thank you so much for looking into this and extending the FilterProperty event! I'm looking forward to the update.

    It's really strange what they do in XAF... I hope this is the last weird thing I had to bother you with for some time. :-)

    Regards

    Marco
  • edited 6:47AM
    Alex, just to let you know: Your changes fixed all the problems I had! Thanks again! I'll keep you updated on how my XAF module comes along. If you're interested we could offer a "package deal" to developers using XAF who want to switch to FastReport.

    Regards

    Marco

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.