Linq to Entities中的子查询抛出异常

时间:2016-09-28 20:21:46

标签: c# entity-framework linq linq-to-entities subquery

我有一个问题,我不知道,我的项目有很多查询使用linq实体和​​子查询,这些都适用于其他人,但当我尝试在我的电脑上运行它们所有的查询返回&#34 ;在此上下文中仅支持基本类型或枚举类型"。

看看这个例子:

 var  questoesRetorno = (from q in questoes
         join p in ctx.tblConcurso_Provas on q.intProvaID equals p.intProvaID
         join c in ctx.tblConcursoes on p.ID_CONCURSO equals c.ID_CONCURSO
         join favorita1 in favoritos on q.intQuestaoID equals favorita1.IdQuestao into favorita2
         from favorita in favorita2.DefaultIfEmpty()
         select new PPQuestao
         {
             Id = q.intQuestaoID,
             Ano = q.intYear.Value,
             Ordem = q.intOrder.Value,
             Prova = new Prova()
             {
                 ID = p.intProvaID
             },
             Concurso = new Concurso()
             {
                 Ano = c.VL_ANO_CONCURSO.Value,
                 Sigla = c.SG_CONCURSO.Trim(),
                 UF = c.CD_UF.Trim()
             },
             FavoritadaPor = favorita.Professor,
             EmClassificacaoPor = (from emClassificacao in ctx.tblConcursoQuestaoEmClassificacao
                                   join pessoa in ctx.tblPersons on emClassificacao.intEmployeeID equals pessoa.intContactID
                                   where emClassificacao.intQuestaoID == q.intQuestaoID
                                       && emClassificacao.intEmployeeID != pp.FiltroIntEmployeeID
                                   select new Professor
                                   {
                                       ID = pessoa.intContactID,
                                       Nome = pessoa.txtName,
                                       DataAcao = emClassificacao.dteDateTime
                                   }).FirstOrDefault()
    })
    .Distinct()
    .ToList();

1 个答案:

答案 0 :(得分:0)

问题解决了!尽管看起来令人难以置信,但问题是视觉工作室2015刚刚卸载并安装了Visual Studio 2013,该项目又开始重新运作。