Page 1 of 1

BusinessObject source doesn't populate members of C# anonymous type

Posted: Fri Sep 02, 2011 8:17 pm
by jkoo
For example, in the below code, Name and Company of 'Department' are not displayed in dictionary.
But when anonymous type is used at collection, it works fines(Looks at the Phones).
It happens at both winform and web.
Please refer to the below image.

Thanks

Code: Select all

var data = from EmployeeITypedList emp in CreateBusinessObjectsITypedList.GetEmployees()
                   select (
                   new
                   {
                       Name = emp.EmployeeName,
                       Department = new { Name = emp.Department.DepartmentName, Company = emp.Department.Company.CompanyName},
                       Phones = from Phone phone in emp.Phones
                                select (new { Area = "xxx", Number = phone.Number })
                   }
                   );

        report.RegBusinessObject("employee", data);

BusinessObject source doesn't populate members of C# anonymous type

Posted: Mon Sep 05, 2011 3:35 am
by HighAley
Hello.
jkoo wrote:For example, in the below code, Name and Company of 'Department' are not displayed in dictionary.
But when anonymous type is used at collection, it works fines(Looks at the Phones).
It happens at both winform and web.
Please refer to the below image.
For working with Business Objects we present Business Object structure as structure of subclasses. Then this structure is used while compiling report and to receive data while rendering report.

But if you use anonymous types in runtime impossible to determine type of object due to a strange error in .NET Framework that occurs when you try to get the type of an anonymous object. Accordingly, we can not properly create the class structure, compile a report and then get the data.

Therefore, we do not support with anonymous types.

Thank you.

BusinessObject source doesn't populate members of C# anonymous type

Posted: Tue Sep 06, 2011 12:19 pm
by jkoo
Thanks for the explanation.
But I'm wondering why IEnumerable list that have anonymouse type as an element type works fine.
That is,

Code: Select all

from EmployeeITypedList emp in CreateBusinessObjectsITypedList.GetEmployees()
                   select (
                   new
                   {
                         Name = ...;
                    }
                   )

or
Phones = from Phone phone in emp.Phones
                                select (new { Area = "xxx", Number = phone.Number })
I think anoymouse type is working at Emplyoee list and phone list.

And, as I know, anoymouse type is a compile time feature and a not run time.
So I think an anonymous type is no different from any other reference type except fore typename is created automaically.
Sorry for bothering you. I just want to make sure it.

Thanks

BusinessObject source doesn't populate members of C# anonymous type

Posted: Thu Sep 08, 2011 3:00 am
by Alex K.
Hello,

The problem in the Framework is not clear. If you use an items array of the anonymous type, then there is no problem, in other cases, errors occurs. The error occurs in a method that should return the object type.

Thank you.