-1
別のメインカテゴリをカウント順に降順に選択しようとしています。しかし、次のエラーを取得:ここラムダ式を使用して異なる値を順番にソート
DbExpressionBinding requires an input expression with a collection ResultType.
Parameter name: input
は私のコードです:
var Categories = products.Where(p => p.IsActive == true)
.Select(n => n.MainCategory).Distinct().ToArray().OrderByDescending(p => p.Count());
if (Categories != null)
{
int j = 0;
foreach (var Category in Categories)
{
j++;
var brands = products.Where(p => p.IsActive == true && p.MainCategory == Category && p.Brand != string.Empty && p.Brand != null).Select(n => n.Brand).Distinct().ToArray();
if (brands == null || brands.Length == 0)
{
sb.AppendFormat("<li><a href=\"/hi-fi/{1}\" class=\"list-group-item list-group-item-success colordiv\">{0}</a><a href=\"#demo{2}\" data-toggle=\"collapse\" data-parent=\"#MainMenu\" class=\"glyphicon glyphicon-minus minus\"></a>\n", Category, Category.Replace(" ", "-"), j);
}
else
{
//code to list brands}
}
}
}
は私を導いてください。
以下のようにあなたはaboves可能) 'の各グループ –
@StephenMuecke他のクエリにも影響するので、GroupBy()を使用することはできません – user777
他のどのようなクエリですか? 'var brands = products.Where(p => p.IsActive == true && p.MainCategory == Category && p.Brand!= string)というクエリには、 '.GroupBy()') –