I'm feeding a ReportDataSource
with a query using Dapper.
However, I have an empty report, even with an IEnumerable
loaded data.
When you spend a Datatable
works.
How do I pass data from a query using Dapper for ReportViewer
?
this.reportViewer.LocalReport.DataSources.Clear();
DataTable dt = new DataTable();
dt = CN.Query(Sql, param);
Microsoft.Reporting.WinForms.ReportDataSource rprtDTSource = new Microsoft.Reporting.WinForms.ReportDataSource(dt.TableName, dt);
this.reportViewer.LocalReport.DataSources.Add(rprtDTSource);
this.reportViewer.RefreshReport(); –
As I could not find another way to feed my ReportViewer to a query Dapper.Query then downloaded the source and added the code below.
Looks like Dapper now supports the DataTable...
From the test:
Also now supported is using a DataTable as a TableValueParameter:
Not sure how Dapper works, but a datatable is binded like this:
and since I am using C#, I bind data sources like this: