2016-08-22 14 views
0

カテゴリに基づいて商品のリストを返すために、次のコードを書いています。web API GETメソッドで複数のパラメータを渡す

public IEnumerable<Product> GetProductsByCategoryId(string category_id) 
     { 
      return repository.GetAll().Where(
       p => string.Equals(p.Category, category_id, StringComparison.OrdinalIgnoreCase)); 
     } 

メソッド、カテゴリ、ブランドに2つのパラメータを渡したいとします。

public IEnumerable<Product> GetProductsByCategoryBrand(string category, string Brand) 
     { 
} 

カテゴリとブランドの返品方法はどのように見えますか?

+0

具体的な問題を明確にしたり、詳細を追加して必要なものを正確に強調してください。現在書かれているとおり、あなたが求めていることを正確に伝えるのは難しいです。この質問を明らかにするには、[How to Ask](http://stackoverflow.com/help/how-to-ask)ページを参照してください。 – Nkosi

答えて

0
public IEnumerable<Product> GetProductsByCategoryBrand(string category, string Brand) 
{ 
    return repistory.GetAll().Where(
     p => string.Equals(p.Category, category, StringComparison.OrdinalIgnoreCase) 
     && string.Equals(p.Brand, brand, StringComparison.OrdinalIgnoreCase)); 
} 

あなただけ& &演算子を使用して)(どこにあなたの条件をチェーン。ブランドまたはカテゴリのいずれかに一致させる場合は、||

関連する問題