这是我的日程安排课程
namespace Expedia.Lib.BLL.Entities
{
[Table("Schedules", Schema = "Expedia")]
public class Schedule
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int ScheduleId { get; set; }
[ForeignKey("Inventory")]
public int FlightId { get; set; }
public FlightInventory Inventory { get; set; }
[Display(Name = "Departure city")]
public string DepartureCity { get; set; }
[Display(Name = "Arrival city")]
public string DestiationCity { get; set; }
[Display(Name = "Departure date")]
[Required]
public string DepartureDate { get; set; }
[Required]
[Display(Name = "Arrival date")]
public string ArrivalDate { get; set; }
[Required]
[Display(Name = "Departure Time")]
public string Departure { get; set; }
[Required]
[Display(Name = "Arrival Time")]
public string Arrival { get; set; }
[Display(Name = "Price/Ticket")]
public int Price { get; set; }
这是我的FlightInventory类
namespace Expedia.Lib.BLL.Entities
{
[Table("FlightInventory", Schema = "Expedia")]
public class FlightInventory
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int FlightId { get; set; }
[ForeignKey("provider")]
public int providerId { get; set; }
public Provider provider { get; set; }
public bool nonstop { get; set; }
[Display(Name = "Total Seats")]
public int Total { get; set; }
[Display(Name = " Seats booked")]
public int Booked { get; set; }
[Display(Name = " Seats Available")]
public int Available { get; set; }
}
}
这是我的Search.Cshtml
@model IEnumerable<Schedule>
@using Expedia.Lib.BLL.Entities
@using GridMvc.Html;
<head>
<script src="@Url.Content("~/Scripts/gridmvc.min.js")"></script>
<title>Flight Details</title>
<script>
$().ready(function () {
$('#footerContent').appendTo('#myTable tfoot tr td:last');
})
</script>
</head>
@section featured {
<div class="featured">
<div class="content-wrapper">
<h2>Flight Details</h2>
</div>
</div>
}
@using (Html.BeginForm("Ticket", "Home", FormMethod.Get
))
{
<div style="width:70%">
@{
WebGrid grid = @ViewBag.WebGrid;
//new WebGrid(query,canPage:true,rowsPerPage:5);
grid.Pager(WebGridPagerModes.NextPrevious);
}
@grid.GetHtml(tableStyle: "listing-border", headerStyle: "head", alternatingRowStyle: "altRow", htmlAttributes: new { id = "myTable" }, columns: grid.Columns(grid.Column("Your Choice", format: @<text><input name="selectedID" type="radio"
class="choice" style="width:100px" value="@item.ScheduleId " /></text>), grid.Column("DepartureCity", "Departure City"), grid.Column("DestiationCity" , "Destination City"), grid.Column("Departure", "Departure"),grid.Column("Arrival", "Arrival"),grid.Column("Price","Price/Adult" ),grid.Column("Provider"),grid.Column("hello")))
@{
if (grid.TotalRowCount == 0)
{
<span id="footerContent">No match found</span>
}
}
<p><br /><br /><input type="submit" value="Book" name="Book" /></p>
</div>
}
现在,当我写grid.Column(“Inventory.Available”,“可用座位”)以显示可用的座位时,它会显示错误列“Inventory.Available”不存在。如何显示可用的座位数来自库存表在View.The查询返回所有值。请提供任何链接引用(如果可用)