[英]Return function for list of id's
I have method that returns function for companySurveys我有为 companySurveys 返回 function 的方法
Here is it就这个
private Func<IQueryable<Client>, IQueryable<CompanySurvey>> JoinCompanySurvey(int id,
IQueryable<CompanySurvey> companuSurveyQuery)
{
var function = (IQueryable<Client> companies) => from companySurvey in companuSurveyQuery
where companySurvey.Id == id
join company in companies
on companySurvey.CompanyId equals company.CompanyId
into res
from company in res
select companySurvey;
return function;
}
id parameter is companySurvey ID. id 参数是 companySurvey ID。
I need method that can work with list of id's.我需要可以使用 id 列表的方法。
So I can send here List and return function for many companySurveys所以我可以在这里发送列表并返回 function 用于许多公司调查
So same stuff as now, but for many.和现在一样的东西,但对很多人来说。
How I need to rewrite this method?我如何需要重写这个方法?
How about this, change parameter int Id
to IEnumerable<int> ids
and in the func body change companySurvey.Id == id
to ids.Contains(companySurvey.Id)
怎么样,将参数
int Id
更改为IEnumerable<int> ids
并在 func 正文中将 companySurvey.Id companySurvey.Id == id
更改为ids.Contains(companySurvey.Id)
private Func<IQueryable<Client>, IQueryable<CompanySurvey>> JoinCompanySurvey(IEnumberable<int> ids,
IQueryable<CompanySurvey> companuSurveyQuery)
{
var function = (IQueryable<Client> companies) => from companySurvey in companuSurveyQuery
where ids.Contains(companySurvey.Id)
join company in companies
on companySurvey.CompanyId equals company.CompanyId
into res
from company in res
select companySurvey;
return function;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.