Use custom objects as the source for Microsoft Reports (.rdlc)

后端 未结 3 1903
暗喜
暗喜 2021-01-21 23:41

In some instances, I prefer working with custom objects instead of strongly typed datasets and data rows. However, it seems like Microsoft Reporting (included with VS2005) requ

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-22 00:21

    I could never choose one of my own POCOs in Report Data setup from my project to be a model for the report - the alleged 'global' option mentioned in the walkthrough was not there. So I ended up having to edit the XML to define the type and an imitation data source (which does not actually exist in my project).

    I assign the data of type Aies.Core.Model.Invoice.MemberInvoice to the report in code

    reportViewer.LocalReport.DataSources.Add(new ReportDataSource("MemberInvoice", new[] { invoice1 }));
    

    And the custom definition is:

      
        
          
            System.Data.DataSet
            /* Local Connection */
          
          3fe04def-105a-4e9b-99db-630c1f8bb2c9
        
      
      
        
          
            
              MemberId
              System.Int32
            
            
              DateOfIssue
              System.DateTime
            
            
              DateDue
              System.DateTime
            
            
              Amount
              System.Decimal
            
          
          
            MemberInvoice
            /* Local Query */
          
          
            Aies.Core.Model.Invoice
            MemberInvoiceData
            GetInvoices
            System.Collections.Generic.IEnumerable`1[Aies.Core.Model.Invoice.MemberInvoice] GetInvoices()
            Aies.Core.Model.Invoice.MemberInvoiceData, Aies.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
          
        
      
    

提交回复
热议问题