Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Provide data from a code class to the Reporting Services designer in VS 2013

I'm trying to create a local SQL Server Reporting Services report (.rdlc file) and connect this report to some data sets that I generate in code (no direct SQL Server connection).

I create a ReportDataProvider class with some instance methods that return IList<T> for various sets of criteria - but I cannot seem to find a way to make those data providing methods show up in the Reporting Services designer inside Visual Studio 2013.

When I look at the dialog that appears after clicking on Add DataSet on the Datasets node in the Report Data explorer window, I see a ton of my classes listed there - but not my data provider class.

enter image description here

Is there anything special I need to be aware of (make the class static? Decorate it with some attribute?) in order for it to show up in that dropdown list of possible data sources? I tried various things, but have failed to find any way to get this to work properly...

like image 632
marc_s Avatar asked Dec 01 '14 11:12

marc_s


1 Answers

I do some research, and try different ways to add classes. Unfortunatly it happends that you can't see static classes in this designer. I tried different ways but no luck.

For non static classes this manual works for me every time, even with Interfaces like IList, but i don't represent it here:

  1. Make sure that namespace with your Data Report Classes available in your project with .rdlc files. Can be that you need to add reference.
  2. Write Data Report Class and rebuild solution.
  3. Close and reopen .rdlc files in your VS.

I using VS 2013 Ultimate Update 2.

This is my classes:

using System.Collections.Generic;

namespace YourReportNamespace
{
    public class ReportClass
    {
        public List<string> TestReportData()
        {
            return new List<string>();
        }
        public static List<string> StaticTestReportData()
        {
            return new List<string>();
        }
    }


    public class ReportWithFieldsClass 
    {
        private List<string> Data = new List<string>();

        public List<string> TestReportData()
        {
            return Data;
        }

        public List<string> TestReportData2()
        {
            return Data;
        }

        public static List<string> StaticTestReportData()
        {
            return new List<string>();
        }
    }

    public static class ReportWithFieldsStaticClass //This class will not appear
    {
        private static List<string> Data = new List<string>();

        public static List<string> StaticTestReportDataFromField()
        {
            return Data;
        }
        public static List<string> StaticTestReportData()
        {
            return new List<string>();
        }
    }
}

This is what i got in designer after i pass through manual:

enter image description here

like image 140
teo van kot Avatar answered Oct 22 '22 11:10

teo van kot