无法显示链接的字段值表+ ReportViewer(can not display the linked field value table + ReportViewer)

编程入门 行业动态 更新时间:2024-10-25 21:23:24
无法显示链接的字段值表+ ReportViewer(can not display the linked field value table + ReportViewer)

我想要表的显示数据。 我无法显示而不是字段-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();

更多推荐

本文发布于:2023-08-02 20:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1381524.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段   链接   ReportViewer   display   field

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!