Hi Yacine,
Thanks for using Syncfusion products.
If we use join queries in SQL it will return a single data table with merged columns, but entity relationship model returns hierarchy object relational model. Using hierarchy object relational model may raise “cross thread exception” inside ReportViewer when viewing RDLC report. So we have to manually retrieve the relational datable and convert them into business objects instead of directly using the relation data in ReportViewer.
We have prepared a sample based on the above mentioned scenario and it can be downloaded from the following location.
http://www.syncfusion.com/downloads/support/directtrac/general/SampleAppln-1221872365.zip
In the above sample, we have created two entity “Table1Item”, “Table2Item” with hierarchy level as shown in the below snap.
http://www.syncfusion.com/downloads/support/directtrac/general/Snapshot601802890.zip
We have created a class (Emp_Model) with properties of both entities to manually relate the values, because the entity “Table1Item” contains reference of “Table2Item”.
public class Emp_Model { public int Emp_Id { get; set; } .. . . . . } |
The values of “Table1Item” retrieved in code behind(Table1Items.GetQuery().Execute()) and created new “Emp_Model” instances for the rows then assigned the Entity values to business object as shown in the below code snippet.
List<Emp_Model> _empModels = new List<Emp_Model>(); foreach (var item in items) { if (item.Emp_Id.Count() > 0) { foreach (var inner in item.Emp_Id) { Emp_Model _model = new Emp_Model(); _model.Emp_Name = item.Emp_Name; ……….. _empModels.Add(_model); } } else { Emp_Model _model = new Emp_Model(); _model.Emp_Name = item.Emp_Name; ..... _empModels.Add(_model); } } |
And we have to assign the business object collection “empModels” to ReportViewer as shown below.
ReportDataSource dataSource = new ReportDataSource("EmpModel", _empModels); |
Please let us know if you have any questions.
Regards,
Nithya
Hi Yacine,
Thanks for the update and your feedback.
Also tried using an anonymous type but that caused an error in the report viewer |
Our ReportViewer doesn’t support the anonymous data type. We have used reflection GetValue method for get the value from dynamic flattened object and exception will be thrown when we get the value of nested object while we enumerate the business objects properties. As of now we doesn’t handle nested object in Flatten collection. So we suggest you to use data view class approach without the nested object hierarchy. However we will consider this as Feature request and we will implement this feature in any of our upcoming releases. We request you to create a Support Incident (Ticket) to get more details about this. Please log on to our DirectTrac Support System using the below link to create support incidents. https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents |
Please let us know if you have any questions.
Regards,
Nithya