【发布时间】:2012-10-27 05:34:41
【问题描述】:
我有一个绑定到int 的文本框。有一个搜索按钮,它根据文本框中的文本给出结果。如果文本为 12,则应显示所有具有 12 的结果。
对于string,我会使用string.contains。但我不知道在int 的情况下该怎么办。
我正在使用 LINQ 过滤掉结果。
int securityId = Convert.int32(filterColumn.Value, CultureInfo.CurrentCulture);
queryResults=queryResults.Where(generaldata=>generaldata.SecuritiesId.Equals(securityId));
但这不起作用。我试过关注
string securityId = Convert.ToString(filterColumn.Value, CultureInfo.CurrentCulture);
queryResults=queryResults.Where(generaldata=>generaldata.SecuritiesId.ToString().Contains(securityId));
但是得到 LINQ 异常,我不能在表达式中使用 ToString。
【问题讨论】:
-
发布一些您遇到问题的代码?
-
@YograjGupta:请查看更新。