0
私は助けが必要な小さな問題の人がいます。私はフィールドがあるレストランオブジェクトを持っています:districtId、dishId、foodCategoryId、そしてrestaurantName。Linqで少しずつやっています
以下のコードに基づいて、RestaurantTableに一致するものがあれば、districtId配列の入力パラメータからチェックする必要があります。私は使用すべきアイデアを持っています
districtId.ToList().Foreach(blah blah action)
しかし、私は難しいです。お知らせ下さい。前もって感謝します。
マイコードスニペット:
public IEnumerable<Restaurant> GetAllRestaurants(string restaurantName
, int[] districtId
, int dishId = 0
, int foodCategoryId = 0)
{
var q = RestaurantTable.Where(restaurants => restaurants.RestaurantName.Contains(restaurantName.ToLower().Trim())
| restaurants.DishId == dishId
| restaurants.FoodCategoryId == foodCategoryId
| "For each Id's in districtId check if it has a match in restaurants.DistrictId")
return q.ToList();
}
感謝の
||
(論理和)を使用したいです答え、それを試してみましょう。もしそうなら、あなたはその部分を説明できますか?または、districtIdにrestaurant.DistrictIdのいずれかが含まれていれば、それはtrueを返しますか? – graymanyey!出来た!再度ありがとう:D – grayman