Linq子查询Where子句
我需要一些关于thsi linq查询的帮助。这应该是相当简单的,但它是踢我的屁股 我需要使用子查询从主查询中筛选出数据,但我尝试使用的每个路径都会导致失败 子查询本身如下所示。Linq子查询Where子句,linq,filter,subquery,where-clause,Linq,Filter,Subquery,Where Clause,我需要一些关于thsi linq查询的帮助。这应该是相当简单的,但它是踢我的屁股 我需要使用子查询从主查询中筛选出数据,但我尝试使用的每个路径都会导致失败 子查询本身如下所示。 int pk = (from c in context.PtApprovedCertifications where c.FkosParticipant == 112118 && (!excludedActionTypes.Contains(c.FkMLSosCodeA
int pk = (from c in context.PtApprovedCertifications
where c.FkosParticipant == 112118 &&
(!excludedActionTypes.Contains(c.FkMLSosCodeActionType)) &&
c.EffectiveDate <= DateTime.Now &&
c.FkptApprovedCertificationVoidedBy == null
orderby c.EffectiveDate descending,c.PK descending
select c.PK).FirstOrDefault();
IQueryable<PtAMember> result = (from p in context.PtAMembers
where (p.FkptACertification == (from c in context.PtApprovedCertifications
where c.FkosParticipant == p.PtApprovedCertification.OsParticipant.PK &&
(!excludedActionTypes.Contains(c.FkMLSosCodeActionType)) &&
c.EffectiveDate <= DateTime.Now &&
c.FkptApprovedCertificationVoidedBy == null
orderby c.EffectiveDate descending, c.PK descending
select c.PK).FirstOrDefault()) &&
(p.LastName.ToLower().Contains(param.ToLower()) ||
p.FirstName.ToLower().Contains(param.ToLower()) ||
p.SocialSecurityNumber.Contains(param))
select p).Distinct().OrderBy(PtAMembers => PtAMembers.LastName).ThenBy(PtAMember => PtAMember.FirstName);
int pk=(来自context.PtApprovedCertifications中的c
其中c.FkosParticipant==112118&&
(!excludedActionTypes.Contains(c.fkmlsocodeActionType))&&
c、 EffectiveDate如何将子查询转换为查找函数:
Func<int, int> pkLookup = n => (from c in context.PtApprovedCertifications
where c.FkosParticipant == n &&
(!excludedActionTypes.Contains(c.FkMLSosCodeActionType)) &&
c.EffectiveDate <= DateTime.Now &&
c.FkptApprovedCertificationVoidedBy == null
orderby c.EffectiveDate descending,c.PK descending
select c.PK).FirstOrDefault();
Func pkLookup=n=>(来自context.PtApprovedCertifications中的c
其中c.FkosParticipant==n&&
(!excludedActionTypes.Contains(c.fkmlsocodeActionType))&&
c、 EffectiveDate错误消息说什么?我尝试了你的解决方案Jerome,下面是我得到的错误。我应该提到我使用Telerik OpenAccess作为我的ORM,并且在他们的站点上有一个类似的线程,因为这可能不是LINQ问题,而是OpenAccess问题。错误消息-调用参数不是参数表达式会话参数名称:invocationExpression实际值为Invoke(值(EliteXtender.EliteDataService.Domain.Residents+c_uDisplayClass3)。pkLookup,p.PtApprovedCertification.OsParticipant.PK)。StackTrace-at Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQueryImpl(类型,Int32 elementAt,Object[]groupResolutionParamValues)位于Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQuery(类型类型,Int32 elementAt,对象[]groupResolutionParamValues)