c# – 将代码类中的数据提供给VS 2013中的Reporting Services设计器

我正在尝试创建本地sql Server Reporting Services报告(.rdlc文件),并将此报告连接到我在代码生成的一些数据集(无直接sql Server连接).

我创建一个ReportDataProvider类,其中有一些实例方法返回IList< T>对于各种标准 – 但我似乎找不到一种方法,使这些数据提供方法显示在Visual Studio 2013中的Reporting Services设计器中.

当我查看在Report Data Explorer窗口中的“数据集”节点上单击“添加数据集”后出现的对话框时,我会看到一大堆列出的类,而不是我的数据提供者类.

有什么特别的我需要注意(使类静态吗?用一些属性装饰它),以便它显示在可能的数据源的下拉列表中?我尝试过各种各样的事情,但没有找到任何方法让它正常工作…

解决方法

我做了一些研究,并尝试不同的方式来添加类.不幸的是,这个设计师看不到静态类.我尝试了不同的方法,但没有运气.

对于非静态类,这个手册每次都适用于我,即使是像IList这样的接口,但是我不在这里表示:

>确保您的数据报告类的命名空间在.rdlc文件的项目中可用.可以这样,你需要添加引用.
>写数据报告类并重建解决方案.
>关闭并重新打开VS中的.rdlc文件.

我使用VS 2013 Ultimate Update 2.

这是我的课程:

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>();
        }
    }
}

这是我在设计师通过手册后得到的:

相关文章

在要实现单例模式的类当中添加如下代码:实例化的时候:frmC...
1、如果制作圆角窗体,窗体先继承DOTNETBAR的:public parti...
根据网上资料,自己很粗略的实现了一个winform搜索提示,但是...
近期在做DSOFramer这个控件,打算自己弄一个自定义控件来封装...
今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都...
最近在研究WinWordControl这个控件,因为上级要求在系统里,...