getClientsProjected()
我可以很容易地比较单个值。但是我已经在我的页面上有多个下拉列表,并且我将字符串与昏迷分开,然后我将其用于将其拆分为string[]
,例如__ACCOUNT_SITE = "1234,5678"
(请参阅下面的代码)我试过/ foreach /包含其中没有一个工作...
public IQueryable<ClientViewModel> getClientsProjected(string __ACCOUNT_SITE, string __ACCOUNT)
{
var projectedClients = from c in getClosedSRs()
select new ClientViewModel
{
_ACCOUNT_ID_CSR = c.ACCOUNT_ID_CSR,
_ACCOUNT = c.ACCOUNT,
_ACCOUNT_FAMILY = c.ACCOUNT_FAMILY,
...
...
_ACCOUNT_SITE = c.ACCOUNT_SITE
};
if (String.IsNullOrEmpty(__ACCOUNT) != true && __ACCOUNT != "ALL")
{
//this works fine as an __ACCOUNT is of a single value
projectedClients = projectedClients.Where(c => c._ACCOUNT == __ACCOUNT);
}
if (String.IsNullOrEmpty(__ACCOUNT_SITE) != true && __ACCOUNT_SITE != "ALL")
{
String[] splitSites = __ACCOUNT_SITE.Split(',');
//????????????????????????????????????????????????
}
return projectedClients;
}
现在,对大多数人来说,这将是完全合理的。我读了很多文章,但没找到合适的答案。但是我不能使用Linq2SQL,因为已经使用L2E,接口和ReportViewer构建了我的整个站点。
任何解决方法?
答案 0 :(得分:0)
如果您尝试根据splitSites中的值过滤projectionClients,请使用:
if (String.IsNullOrEmpty(__ACCOUNT_SITE) != true && __ACCOUNT_SITE != "ALL")
{
String[] splitSites = __ACCOUNT_SITE.Split(',');
projectedClients = projectedClients.Where(x => splitSites.Contains(x._ACCOUNT);
}