开发者

can not display the linked field value table + ReportViewer

I want display data of table. And I can't display instead of the fields-id their value from the table to which they refer.

I add new item - Reportint-> Report (*.rdcl) and than add on the web form ReportViewer. VS dispayed wizard and I add new DataSet where choise my business method for select data.

I have table Inhabitans it contain FacultyID field, but I want see Value from linked table where Inhabitans.FacultyID == Faculty.FacultyID.

public List<Inhabitant> SelectAllWithoutParameters()
    {
        using (DataContext dc = Infrastructure.DataContext)
        {
            DataLoadOptions options = new DataLoadOptions();
            options.LoadWith<Inhabitant>(u => u.Faculty);
            dc.LoadOptions = options;
            List<Inhabitant> inhs = dc.GetTable<Inhabitant>().OrderBy(u => u.FullName).ToList();
            return inhs;
        }
    }

Click Insert - 开发者_开发百科New Table. I can choose all fields from Inhabitant, but not from Faculty.

How to solve this problem


I don't know anything about rdcl reports, but I would create a new class to project the data into, something like InhabitantReport.

Then you just change this line:

List<Inhabitant> inhs = dc.GetTable<Inhabitant>().OrderBy(u => u.FullName).ToList();

to something like this:

List<InhabitantReport> inhs = dc.GetTable<Inhabitant>().OrderBy(u => u.FullName).Select(r=>new InhabitantReport() 
{
 //Populate data.
}).ToList();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜