我有一个模型如下,想显示来自 4 个不同表的项目。
public class AuctionViewer
{
public int AuctionId { get; set; }
public string ProductName { get; set; }
public int Price { get; set; }
public DateTime startTime { get; set; }
public DateTime EndTime { get; set; }
public string Category { get; set; }
public int ExpectedHit { get; set; }
public string Status { get; set; }
}
下面是我的控制器代码。
public ActionResult Index()
{
MightyMouseContainer ctx = new MightyMouseContainer();
var NewList = new AuctionViewer
{
from CT in ctx.Categories
join PD in ctx.Items on CT.Category_ID equals PD.Category_ID
join AU in ctx.Auction_Schedule on PD.Item_ID equals AU.Item_ID
join ST in ctx.Status on AU.Status_ID equals ST.Status1
orderby AU.Auction_ID
select new
{
AuctionId = AU.Auction_ID,
ProductName = PD.Item_name,
Price= PD.Item_Value,
startTime = AU.Start_Time,
EndTime = AU.End_Time,
Category = CT.Category_Description,
Status = ST.Description
};
}
return View(NewList);
}
我想知道为什么会出现错误。请指教。我已经为此工作了很长一段时间,并意识到我需要一些帮助才能继续前进。我将感谢其他人的迅速反应以继续前进。谢谢