实体框架在尝试实现查询时触发错误

时间:2018-09-13 15:09:48

标签: c# entity-framework linq

我有此代码:

public IEnumerable<InvestSurveyQuestion> GetInvestSurveyQuestion()
{
    var context = Context as OracleDataContextCommon;

    var query = (from sa in 
                    (from questions in context.ScoringQuestions
                    join sa in context.ScoringAnswers on questions.SquId equals sa.SquId
                    group sa.SanId by sa.SquId into g
                    select new
                    {
                        squId = g.Key,
                        sanIds = g.ToList()
                    })
                    join sq in context.ScoringQuestions on sa.squId equals sq.SquId
                    select new InvestSurveyQuestion
                    {
                        Id = sq.SquId,
                        SqgId = sq.SqgId,
                        SanIds = sa.sanIds
                    });

    return query.ToList();
}

如果我尝试使用ToList()来实现查询,则会触发我无法理解的错误:

  

类型'System.Data.Entity.Infrastructure.ObjectReferenceEqualityComparer'的表达式不能用于类型'System.Collections.Generic.IEqualityComparer`1 [System.Int32]'的构造函数参数

我在这里做什么错了?

0 个答案:

没有答案