VB.Net: How to use an object data source in a report (.rdlc)

My question is similar to this , but I am having some problems with the actual implementation.

I have a report (.rdlc) at the business level of a 3-tier application.

I have an object in BL ( EmployeeManager) that has a method GetEmployees(Expression as Expression(Of Func(Of Employee, Boolean))) As IQueryable(Of Employee).

Since I did not want to try to pass the lambda directly (at least until something works for me), I created a class ReportDatain BL that wraps the call GetEmployees()and displays the results as IEnumerable (Of Employee) - this should be very simple. Currently, it does not even have parameters.

Ok ... So, in my report, I tried to add a new data source. I selected the type Objectand found the class ReportDatamentioned above. The wizard completes and adds the DataSources folder to the project, inside which there is some XML that defines <GenericObjectDataSource>and points to the class Report.

ReportDataalso appears in the Data Sources panel. There is next to it >, but when I expand it, it has no children.

I do not know how to do this - USE the data source. He does not seem to disclose any methods / members (I have not even indicated that he should call GetEmployees()yet!), And I certainly can IEnumerable(Of Employee)not.

, , ReportData " ".

? - ?

ReportData:

Namespace Reports
    Public Class ReportData

        Private Property EmployeeManager As Interfaces.IEmployeeManager

        Public Sub New()
            ''This sub is here in case it 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

, , , , ,

" ", .

-

EDIT. , . , . Alex Esselfie . , ...

+2
2

ReportData . , IEnumerable, .

, Employee . .

.



1

Visual Studio 2008

  • Design View.
  • Data > Show Data Sources
  • .
  • "" .
  • , .
    Employee.
  • "" "".


Visual Studio 2010

  • Design View.
  • View > Report Data
  • New > Dataset... .
  • (, Employee)
  • .

    • "" .
    • (), .
    • "".


, .


2

. .
, , , , .

+4

. ( ) , - ( ). (.rdlc) , . . . "" -, rdlc, "", .

+1

Source: https://habr.com/ru/post/1569345/


All Articles