Development-time data source requirements in Report Viewer 2010

What are the requirements for a custom data source to appear in the Data Source drop-down list when adding a dataset to a .rdlc report in Report Viewer 2010?

As you can see from the screen capture, for some reason it lists potential sources from a variety of reference assemblers, but I don't see an obvious pattern as to why it selects them.

alt text

"GeneralDataSet" makes sense, since it is a strongly typed Dataset class, but I'm sure most of the others are not, but the design dialog still lists them.

I am looking to collapse my own custom data source and would prefer it to be selected from this list.

+3
4

, , , < > ..

- :

public class Person
{
    public string name { get; set; }
    public int age { get; set; }
}

public class GetPeople
{
   public List<Person> GetPeopleList()
   {
      return null;
   }

   public IEnumerable<Person> GetPeopleIEnumerable()
   {
      return null;
   }

   public IQueryable<Person> GetPeopleIQueryable()
   {
      return null;
   }
}

, . ( , /:))

ReportViewer, . , , , . ObjectDataSource .

0

, , , .

.. .

public class FooData 
{
    public List<string> Data {get;set;}
}

public class FooData 
{
    public List<string> GetData();
}
0

,

, .

( ). , ReportViewer .

:

public MyObject()
{
}
0

, List. , . .

, , DataSource, DataSet:

public class AccountList : List<AccountData>
{}

This class will NOT be displayed as a dataset, which will prevent its project from appearing as a data source (note the "I" in front of AccountData):

public class AccountList : List<IAccountData>
{}

This is a pain because other aspects of our system require lists to inherit an interface, not a specific class. I do not know why this does not work.

0
source

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


All Articles