I am using Linq to Entities and I have a query something like this
context.Hotels
.Where(h => h.HotelType.Contains(s.HotelTypeId.ToString()))
.Select(hotel => new Model.Hotel
{
HotelId = hotel.HotelID,
HotelName = hotel.HotelName,
HotelFileName = hotel.HotelFileName,
StarRating = hotel.StarRating,
CountryName = hotel.Country.CountryName,
PlaceName = hotel.Place.PlaceName
})
I am using .ToString() in where clause which I know is not valid when work with Linq To Entities. But actually "HotelType" column have values separated with pipe characters like 1|2|3..Now I want to extract only those Hotels that have a type 1..How is it possible? Please help
1|2|3in one cell. You can create another table with the nameHotelTypeswith at least two columns:Hotel_IDandType_ID. Then use join to this table.