none
Access of properties of a property in reports RRS feed

  • Question

  • Hello,

    i'm using MS Reporting services to create list reports. I got an object like this:

    --PersonObject
       +Birth (Property of type Datum, custom class)
           -DateTime
           -Day
           -Month
       +Name
       +Address

    I'm using an Object source in report designer of VisualStudio. If I drag for example Month onto the Report, the Designer writes the VBScript: =Fields!Month.Value. This looks like Month is a property of the object PersonObject, but it's a property of the property Birth (type: Datum). However, if I add the Column Month to the ReportDataSource DataTable, everything works well. Now this isn't a good solution if I got the following object:

    --InVacationPersonObject
       +Birth (Property of type Datum, custom class)
           -DateTime
           -Day
           -Month
       +Left (Property of type Datum, custom class)
           -DateTime
           -Day
           -Month
       +Arriving (Property of type Datum, custom class)
           -DateTime
           -Day
           -Month
       +Name
       +Address

    If I do the same thing as with the PersonObject, Month would be one of Birth-Date, Left-Date or Arriving-Date, but i want it seperated. I desperately searched for a solution, but nowhere found something. Is there a way to access the properties of the Arriving-Property somehow like Fields!Birth.Month.Value or Fields!Left.Month.Value? If it's not implemented, is there any way to solve this problem without avoiding using the custom Datum class?

    greeting
    mfelive
    Thursday, August 20, 2009 8:57 AM

All replies

  • I found a simple solution, which works with the Designer. I wrote a LINQ expression which merges the properties into the main object I need:
    var PersonObjectsEx = from r in PersonObjectList
                                     select new
                                     {
                                         DateTime = r.Birth.DateTime,
                                         r.Name,
                                         r.Address
                                     };
    Now this generates an object with the DateTime property in PersonObject, that's where the ReportDesigner searches it. Using an Extension from this site: http://dotnet-snippets.de/dns/linq-ergebnis-in-datatable-kopieren-SID1002.aspx I can generate a DataTable from the LINQ Expression. Works fine.

    greetings
    mfelive

    Thursday, August 20, 2009 3:11 PM