I have 4 tables in my database namely Restaurants,Cuisines,Facility,Dishes. I have created a table adapter that returns data from these tables. now i have to filter the data based on user selection for cuisine,facility or dishes and return the resultant restaurants. here is my query:
public string alldata(string location, string cuisines, string facility)
{
location = location.Replace('|', ',');
facility = facility.Replace('|', ',');
cuisines = cuisines.Replace('|', ',');
string loc; string data = null; int id;
DataSet3.DataTable1DataTable all = getall.GetAllData();
IEnumerable<DataRow> query = from resturants in all.AsEnumerable()
where ((location.Contains(resturants.City)) && (facility.Contains(resturants.FacilityName) && (cuisines.Contains(resturants.Type))))
select resturants;
foreach (DataSet3.DataTable1Row item in query)
{
name = item.Name;
loc = item.Location;
id = item.RestaurantID;
data += name + "%" + loc +"%"+id+ "?";
}
return data;
}
this query returns duplicate entries and it does not apply AND in selection. I am stuck. please help me.