Let me show the actual classes I’m using and the results I get using different values for the recursion depth.
This is my report data class:
public class EmployeeVisitorReportData
{
public Visitor Visitor { get; set; }
public PersonName EmployeeName { get; set; }
public string ReasonForVisit { get; set; }
public string CategoryName { get; set; }
public DateTimeOffset EntryTimeIn { get; set; }
public DateTimeOffset EntryTimeOut { get; set; }
public string CustomId { get; set; }
}
Visitor is a LINQ-to-SQL entity class, with a number of simple types that map to a SQL Server database table.
PersonName is a class that has two get/set properties: FirstName and LastName. It also has a few read-only properties that format the first and last name. The read-only property names are:
- FirstNameLastName
- FirstInitialLastName
- LastNameFirstName
- LastNameFirstInitial
So here’s where my understanding of the ObjectDataSource and the recursion depth stuff falls flat. If I set the FlattenStructure setting to true, I get an OutOfMemory exception, regardless of the recustion depth value.
If I set the recustion depth to 0, and then design a report with an instance of the EmployeeVisitorReportData class, while adding the report container object I choose Table and have two entries to choose from:
- Free content
- EmployeeVisitorReportData
If I choose EmployeeVisitorReportData then I can see these fields available for me to drop onto the report:
- CategoryName
- CustomId
- EntryTimeIn
- EntryTimeOut
- ReasonForVisit
The Visitor and EmployeeName fields have been removed from the object for some reason. I can drop these 5 fields onto the report and they work correctly and display all the data correctly. But why can’t I access Visitor and EmployeeName?
If I design the report using the same technique just described, except use a recursion depth of 1, I am presented these fields that I can add to the report:
- Free content
- EmployeeName
- EmployeeVisitorReportData
- Visitor
If I pick EmployeeName, I can choose from all the properties in the PersonName class, but cannot see EmployeeVisitorReportData or Visitor so cannot place them on the report. Why is that? If I choose the Visitor field, I can see all of those fields just fine but cannot see the EmployeeName and EmployeeVisitorReportData fields. Why can’t I see the whole record structure?
If I expand the EmployeeVisitorReportData node I am shown the EmployeeName and Visitor fields. If I choose EmployeeName I’m allowed to add EmployeeName’s 6 fields and EmployeeVisitorReportData’s 5 fields onto the report, but the Visitor field is nowhere to be seen. Why? Likewise, if I choose Visitor rather than EmployeeName from the EmployeeVisitorReportData node, I can place any of the 5 EmployeeVisitorReportData fields on the report and/or all 50 (or so) of the Visitor fields on the report, but now EmployeeName is nowhere to be seen. Why?
If I pick a recusion depth of 2 or higher I seem to get a deeper picture of the LINQ-to-SQL structure, but I don’t know what the purpose of that is because none of those deeper levels are populated with data with the query I am using. Seems to me the only useful recursion depth level is 1, at least with a LINQ-to-SQL query as the data source. Do I understand this correctly?
I know this is a long description (wish I could post screen shots here to simplify this) but don’t know how else to describe the issues I’m seeing without this long example. I’ve highlighted my questions above, if that helps any.
Is the idea that I have to use a flat data structure and cannot have a hierarchy of properties for my report data? But then why can I sometimes see two hierarchies (e.g., EmployeeVisitorReportData + Visitor) but not all three hierarchives (e.g., EmployeeVisitorReportData + Visitor + EmployeeName)? If I have to use a “flat” class that won’t work so well because some of these fields, like Visitor, has many properties that would have to be defined and then populated.
Thanks for any help understanding how this is supposed to work.