我需要从列表中获取项目,但是从另一个id列表中过滤id。这是我的代码,我无法弄清楚问题。有什么帮助吗?
var lstStatus = new List<int> {(int) SurveyRequestConstants.EnumSurveyRequestStatus.Open,
(int) SurveyRequestConstants.EnumSurveyRequestStatus.InProgress,
(int) SurveyRequestConstants.EnumSurveyRequestStatus.OnHold};
var surveyRequestList = SurveyRequestRepository.Queryable().AsEnumerable().ToList();
var surveyRequests = (from first in surveyRequestList
join second in lstStatus
on first.SurveyRequestStatus.Id equals second
select new ListItem(string.Format("{0} {1} {2}",
first.Id.ToString(),
first.Tenant.TenantLabel,
first.CreatedDate),
first.Id.ToString())).ToList();
答案 0 :(得分:0)
以下是根据lstStatus
中的项目过滤surveyRequestList的代码var surveyRequests = surveyRequestList
.Where(x => lstStatus
.Any(y => y == x.Id))
.Select(x => new ListItem(string.Format("{0} {1} {2}",
first.Id.ToString(),
first.Tenant.TenantLabel,
first.CreatedDate),
first.Id.ToString()));
希望这是你在找什么?