我有一个显示报告的详细信息页面,我现在需要一个显示多个报告的索引页面。我已经成功地进行了设置(我可以选择用户页面上的复选框并在“打印页面”上显示一些信息,但我不知道如何显示相关信息。
我的详细信息包含这样的用户 ID -
public ViewResult Details(string id)
{
User user = db.Users
.Include(i => i.UserDetails)
.Include(i => i.TRS)
.Include(i => i.Pension)
.Include(i => i.LifeAssurance)
.Include(i => i.IncomeProtection)
.Where(i => i.UserName == id)
.Single();
string pensionProviderName = providerRepository.GetProviderByID(user.Pension.PensionProviderID).ProviderName;
TRSViewModel viewModel = new TRSViewModel
{
UserName = user.UserName,
FirstName = user.UserDetails.FirstName,
LastName = user.UserDetails.LastName,
Salary = user.UserDetails.Salary,
PensionSchemeName = pensionSchemeName
但在我的索引中我有
public ViewResult Index(FormCollection form)
{
string[] UserIDs = form["TRSIDs"].Split(',');
var trs = db.Users
.Include(t => t.UserDetails)
.Include(t => t.TRS)
.Include(t => t.Pension)
.Where(g => UserIDs.Contains(g.UserName))
.Select(user => new TRSViewModel
{
UserName = user.UserName,
FirstName = user.UserDetails.FirstName,
LastName = user.UserDetails.LastName,
Salary = user.UserDetails.Salary
但我不知道如何在视图模型中包含“PensionSchemeName”详细信息。我尝试直接使用 -
PensionSchemeName = db.SchemeNames.Find(user.Pension.PensionSchemeNameID).Name,
但我得到了一个错误。有什么想法可以包括这个吗?