Retrieving data in razor functions

I have three types of global data Tour Hotel Airline

I created a razor function to display a tour with relevant information about the hotel and airline. But I can not get information about the airlines and hotels in my function. Here is the code:

    @foreach (var Tour in Data.Get<Countries.Tour>())
{
     @Tour.Airline.Name 
    <img src='~/media(@Tour.Thumb)'  />
}

@ Tour.Airline.Name does not work. I cannot save the function of either @ Tour.Airline, which displays only the Guid airline, and not the name of the airline.

so what do you recommend? using the xslt function? or create an auxiliary function to convey the leadership of the airline and get the aerolock data, which, in my opinion, makes the system a little complicated.

+4
source share
1 answer

C1 " ", (, int, guid ..), .

, - :

var myList = from tour in Data.Get<Countries.Tour>()
join airline in Data.Get<Countries.Airline>() on tour.Airline equals airline.Id
select new { airline.Name, tour.Thumb};

@foreach (var element in myList)
{
     @element.Name 
    <img src='~/media(@element.Thumb)'  />
}

. LINQ to SQL?

+2

Source: https://habr.com/ru/post/1583934/


All Articles