我想要表的显示数据。 我无法显示而不是字段-id来自他们所引用的表的值。
我添加新项目 - Reportint-> Report(* .rdcl),然后在Web表单上添加ReportViewer。 VS dispayed向导,我添加新的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; } }单击“插入 - 新表”。 我可以选择居民中的所有字段,但不能选择Faculty。
如何解决这个问题呢
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
最满意答案
我对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();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();更多推荐
发布评论