0

I'm needing to do a join from multiple tables and wondering how I display the results back to a list I can use on the front end. I'm using 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};

Front end code

@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>
}

Really not sure how to approach this. Thanks.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
PixelMuse
  • 470
  • 8
  • 24

0 Answers0