如何在C# LINQ的Where子句中筛选关联的SourceEndpointConfigs数据
问题:从已获取的_vwSourceEndpoints集合关联查询对应SourceEndpointConfigs数据
我需要从已经获取到的_vwSourceEndpoints集合中,筛选出与之对应的SourceEndpointConfigs数据,但不知道该如何修改Where子句才能得到正确结果,以下是原始代码和我尝试修改后的代码:
原始代码
_vwSourceEndpoints = db.vwSourceEndpoints .Where(e => e.StudySourceSystemId == study.StudySourceSystemId & e.ScheduleId == study.ScheduleId & e.OrderNo == study.OrderNo & e.Active == true ).ToList(); _vwSourceEndpointConfigs = db.SourceEndpointConfigs.Where( e => e.Active == true ).ToList(); var query3 = _vwSourceEndpointConfigs.Concat(_vwSourceEndpoints.OrderBy(x => x.OrderNo).ToList();
修改后的尝试代码
_vwSourceEndpoints = db.vwSourceEndpoints.Where( e => e.StudySourceSystemId == study.StudySourceSystemId & e.ScheduleId == study.ScheduleId & e.OrderNo == study.OrderNo & e.Active == true).ToList(); _vwSourceEndpointConfigs = db.SourceEndpointConfigs.Where( e => _vwSourceEndpoints.All(x => x.StudySourceSystemId == study.StudySourceSystemId & x.ScheduleId == study.ScheduleId & x.OrderNo == study.OrderNo & x.Active == true) ).ToList();
内容的提问来源于stack exchange,提问作者Adam Mohammed Dabdoub
相关产品推荐
相关产品推荐

