微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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

原文地址:https://www.jb51.cc/csharp/94912.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐