为了账号安全,请及时绑定邮箱和手机立即绑定

在单视图MVC中显示多个表

在单视图MVC中显示多个表

C#
交互式爱情 2021-04-05 14:17:53
我有两个相互关联的表。我希望能够在一个视图中同时查看信息。但是,当我尝试使用VolumeRates表中的属性时,出现错误:错误CS1061'ICollection'不包含'BidRate'的定义,并且找不到找到接受类型为'ICollection'的第一个参数的扩展方法'BidRate'(您是否缺少using指令或程序集引用?)TimberSales C:\ Users \ kraskell.CDATRIBE2 \ Documents \ Visual Studio 2017 \ Projects \ TimberSales \ TimberSales \ Controllers \ DataEntryController.cs 18有效我模型的代码是using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using TimberSales.Models;namespace TimberSales.Controllers{    public class DataEntryController : Controller    {        // GET: DataEntry        public ActionResult Index()        {            TimberSalesEntities db = new TimberSalesEntities();            List<TimberSale> timberSales = db.TimberSales.ToList();            List<DataEntry> dataEntries = timberSales.Select(x => new DataEntry { ContractNumberTimberSales = x.ContractNumber, BidRate = x.VolumesRates.BidRate }).ToList();            return View(dataEntries);        }    }}该TimberSales对象包含VolumeRates对象列表我需要做select join才能访问,我需要的信息,或者我可以做到这一点的范围内TimberSales.Select,以显示我需要的信息陈述,或者我需要修改@model IEnumerable<TimberSales.Models.DataEntry>的index.cshtml?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 187 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信