Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# .NET MVC在计数()时返回错误_C#_Asp.net Mvc - Fatal编程技术网

C# .NET MVC在计数()时返回错误

C# .NET MVC在计数()时返回错误,c#,asp.net-mvc,C#,Asp.net Mvc,我有一个问题: foreach (var item in outcomeAreas) { var outcomeAreasCohorts = db.Cohorts .Join(db.OutcomeArea, c => c.ID, oa => oa.CohortID, (c, oa) => new { c = c, oa = oa }) .Where(oa => oa.oa.OutcomeType.Contains(item.SubC

我有一个问题:

foreach (var item in outcomeAreas)
{
    var outcomeAreasCohorts = db.Cohorts
        .Join(db.OutcomeArea, c => c.ID, oa => oa.CohortID, (c, oa) => new { c = c, oa = oa })
        .Where(oa => oa.oa.OutcomeType.Contains(item.SubCategory.ToString()))
        .Select(c => new { c.c.cohortID }).Distinct().ToList().Count();

    allFilters.Add(new GetFilters { Category = item.Category, Identifier = item.Identifier, SubCategory = item.SubCategory, SubCategoryIdentifier = item.SubCategory.ToString().Replace(" ", "-"), TopLevel = "Key Cohort Outcomes", TotalNum = outcomeAreasCohorts.ToString() });
}

然而,这给我带来了一个错误

Values of type 'collection[Edm.String(Nullable=True,DefaultValue=,MaxLength=,Unicode=,FixedLength=)]' can not be converted to string.

我尝试搜索,但没有找到此错误。想法?

尝试删除该实体并将其添加回edmx。通常有效。你是说把它从课堂上移除吗?明白了。谢谢