我有一个带有字符串类型参数'baan_cat_fam_code'的对象。下面的代码是我尝试查找查询中所有具有在通用字符串列表中存在的baan_cat_fam_code的项目catFamCd。
query = query.Where(r => r.baan_cat_family_code.Any(s => catFamCode.Contains(s)));
问题在于这段代码无法编译——我收到了一个错误提示。
"Argument type 'char' is not assignable to parameter type 'string'"
由于某些原因,谓词s被定义为字符类型。所以我在.Contains方法的参数中添加了.ToString()。但是,当代码运行时,将查询结果绑定到列表框时,会抛出以下异常。
"The argument 'value' was the wrong type. Expected 'System.Char'. Actual 'System.String'."
这让我感到困惑。非常感谢您的帮助。
谢谢!