My question is similar to this one but I'm having some problems with the actual implementation.
I've got a report (.rdlc) in the business layer of a 3-tier app.
I've got an object in the BL (EmployeeManager
) which has a GetEmployees(Expression as Expression(Of Func(Of Employee, Boolean))) As IQueryable(Of Employee)
method.
As I didn't want to try and pass a lambda in directly (at least not until I've got something working), I've created a ReportData
class in the BL which wraps the GetEmployees()
call and exposes the results as an IEnumerable(Of Employee) - which should be very simple. It doesn't even have parameters at the moment.
Ok... So In my report, I've tried to add a new Data Source. I've picked a type of Object
and located the ReportData
class mentioned above. The wizard completes and adds a DataSources folder to the project inside which is some XML defining a <GenericObjectDataSource>
and pointing at the Report
class.
ReportData
also appears in the Data Sources pane - It has a ">" next to it but when I expand it, it has no children.
What I don't know how to do is USE the data source - It doesn't seem to expose any methods/members (I haven't even specified that it should call GetEmployees()
yet!) and I certainly can't see an IEnumerable(Of Employee)
anywhere.
When I try to add a table to the report and it prompts me to select a Dataset, the ReportData Datasource is not shown in the Data source drop-down.
What am I missing? Can someone please point me in the right direction?
Many thanks
My simple ReportData object:
Namespace Reports
Public Class ReportData
Private Property EmployeeManager As Interfaces.IEmployeeManager
Public Sub New()
''This sub is here in case it's an instantiation problem - I intend to use dependency injection when I've got this working properly.
Me.EmployeeManager = New EmployeeManager
End Sub
Public Sub New(ByVal EmployeeManager As Interfaces.IEmployeeManager)
Me.EmployeeManager = EmployeeManager
End Sub
Public Function GetEmployees() As IEnumerable(Of Employee)
Return EmployeeManager.GetEmployees()
End Function
End Class
End Namespace
I've also found this which seems to indicate I'm following the correct steps but the properties don't appear as expected
The public properties of the class now appear in the Data Sources window, where they can be dragged and dropped into the report.
This doesn't happen - the properties never appear
EDIT: As pointed out by Alex, I need to use properties not just any methods. Please see Alex Esselfie's answer below for clarification. This still hasn't solved my problem but has got me a step closer...