mardi 5 juillet 2016

I want to write a query that displays guest and hotel data using Those GuestId and HotelId foreign keys

public IList<CommentsDetailsDto> GetComments()
{
    return db.Comments.Select(p => new CommentsDetailsDto
    {
        Rating = p.Rating,
        Description = p.Description,
        GuestId = p.GuestId,   /*foreign key*/
        HotelId = p.HotelId,   /*  foreign key     */ 
        }).ToList();
    }

comments table contains hotelid and guestid as foreign key. the api returns hotel id and guest id but i want to get fields like hotel name and guest name from the table. how do i go about it




Aucun commentaire:

Enregistrer un commentaire