public class hotelapiController : ApiController
{
private POSDBEntities db = new POSDBEntities();
public IList<HotelsDetailsDto> GetHotels()
{
return db.Hotels.Select(p => new HotelsDetailsDto
{
Id = p.Id,
Name = p.Name,
Address = p.Address,
Description = p.Description,
Offering = p.Offering,
Gps = p.Gps,
NumberOfRooms = p.NumberOfRooms,
Commission = p.Commission,
Rating = p.Rating,
HotelTypeName=p.HotelTypeName,
HimageId = p.HimageId, //HimageId is a foreign key
AveragePrice=p.AveragePrice,
BookingEmail =p.BookingEmail,
LocationId =p.LocationId, //LocationId is a foreign key
}).ToList();
}
When postman returns the JSON data it returns only the ids of the foreign key. But I need it to return data in the location table ie Name and Image of the Location not only the Location Id. Im using data transer objects and Database First approach not code first. How do i go about i?