如何使用“In”在实体框架中使用子查询 [英] How to use "In" with subquery in entity framework

查看:81
本文介绍了如何使用“In”在实体框架中使用子查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我使用实体框架在以下查询的帮助下从数据库获取结果:



Hi,

I am using entity framework for getting the result from database with the help of the following query:

var resManagerGroup = (from objManagerGroup in objEntities.LK_MANAGER_GROUP
                                  where objManagerGroup.user_id == iManagerId && objManagerGroup.group_id != null
                                  select new
                                  {
                                      groupId = objManagerGroup.group_id
                                  });

           var resAssessmentForMarking = (from objAssessmentsForEvaluation in objEntities.UL_ASSESSMENT_EVALUATION_BY_MANAGER
                                          where (objAssessmentsForEvaluation.assessing_status == 0 || objAssessmentsForEvaluation.assessing_status == 1)
                                          && objAssessmentsForEvaluation.courseLinkId != null
                                          select new
                                          {
                                              assessmentId = objAssessmentsForEvaluation.assessment_Id,
                                              groupId = objAssessmentsForEvaluation.group_Id
                                          });

    resAssessmentForMarking = resAssessmentForMarking.Where(s => resManagerGroup.Contains(s.groupId));

< br $>




但我收到以下错误:



错误20' System.Linq.IQueryable< int>'不包含'Contains'的定义和最佳扩展方法重载'System.Linq.ParallelEnumerable.Contains< tsource>(System.Linq.ParallelQuery< tsource>,TSource)'有一些无效的论点



请建议一些解决方案。



谢谢,



问候,

Ashish




but I am getting the following error:

Error 20 'System.Linq.IQueryable<int>' does not contain a definition for 'Contains' and the best extension method overload 'System.Linq.ParallelEnumerable.Contains<tsource>(System.Linq.ParallelQuery<tsource>, TSource)' has some invalid arguments

Please suggest some solution.

Thanks,

Regards,
Ashish

推荐答案

检查出来

http://stackoverflow.com/questions/2066084/in-operator-in-linq? answertab = active#tab-top [ ^ ]


这篇关于如何使用“In”在实体框架中使用子查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆