无法显示链接字段值表+ ReportViewer

问题描述

| 我想显示表的数据。而且我无法显示字段ID而不是它们所引用的表中的值。 我添加新项目-Reportint->报告(* .rdcl),然后在Web窗体ReportViewer上添加。 VS支付向导,我添加了新的DataSet,在其中选择了我的业务方法来选择数据。 我有表Inhabitans,它包含FacultyID字段,但是我想从链接表中看到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;
        }
    }
单击插入-新建表。我可以从居民中选择所有领域,但不能从学院中选择。 如何解决这个问题呢     

解决方法

        我对rdcl报告一无所知,但是我会创建一个新类来将数据投影到其中,例如InhabitantReport。 然后,您只需更改此行:
List<Inhabitant> inhs = dc.GetTable<Inhabitant>().OrderBy(u => u.FullName).ToList();
像这样:
List<InhabitantReport> inhs = dc.GetTable<Inhabitant>().OrderBy(u => u.FullName).Select(r=>new InhabitantReport() 
{
 //Populate data.
}).ToList();