gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 22:12:24 26 4
gpt4 key购买 nike

我要显示表格的数据。而且我无法显示它们引用的表中的值,而不是字段 ID。

我添加了新项目 - Reportint-> Report (*.rdcl),然后在 Web 表单 ReportViewer 上添加。VS 已显示向导,我添加了新的数据集,在其中选择我的业务方法来选择数据。

我有表 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;
}
}

单击插入 - 新表。我可以选择 Inhabitant 中的所有字段,但不能选择 Faculty 中的所有字段。

如何解决这个问题

最佳答案

我对 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();

关于c# - 无法显示链接字段值表+ReportViewer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6168295/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com