我需要从多个表进行联接,想知道如何将结果显示回可以在前端使用的列表。我正在使用RazorPages。
var vehicleQuery = from vehicle in _context.Vehicle
join color in _context.ExteriorColor on vehicle.ExteriorColor.Id equals color.Id
join model in _context.VehicleModel on vehicle.VehicleModel.Id equals model.Id
orderby vehicle.Id
where (vehicle.IsAvailable)
select new { vehicle, color, model};
前端代码
@foreach (var vehicle in Model.VehicleList)
{
<input type="hidden" name="Package.Index" value="@vehicle" />
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="vehicles-box">
<div class="vehicles-thumb">
<img src="img/demo/test.jpg" alt="" />
<a class="property-sh-more" href="~/VehicleDetail"><i class="fa fa-angle-double-right"> </i><i class="fa fa-angle-double-right"> </i></a>
<p class="car-info-small">
@vehicle.Year<br>
@vehicle.VehicleModel.MbModel<br>
@vehicle.ExteriorColor.Description<br>
@vehicle.Upholstery.Description<br/>
</p>
</div>
<h3><a href="~/VehicleDetail" title="Mercedes-Benz">@vehicle.Style.StyleName</a></h3>
<span class="price">$@vehicle.Price</span>
</div>
</div>
}
真的不确定该如何处理。谢谢。