[英]Uncaught TypeError: Cannot call method 'Where' of undefined
I am not sure what could be the cause of this error but i am trying to return results using linq query like statement to loop through a list of positions and then another loop to get all users for each of the positions. 我不确定造成此错误的原因是什么,但我试图使用linq查询(如语句)返回结果以循环浏览职位列表,然后进行另一个循环以获取每个职位的所有用户。
linq is Enumerable linq是可数的
var getList = function () {
Ajax.Get({
Url: ...,
DataToSubmit: {id: properties.Id },
DataType: "json",
OnSuccess: function (roleData, status, jqXHR) {
// bind role types
bindModel(roleData);
console.log("roles:", roleData.length);
Ajax.Get({
Url: ....,
DataToSubmit: { pageNumber: 1, id: properties.Id },
DataType: "json",
OnSuccess: function (userData, status, jqXHR) {
console.log("users", userData.length);
var results = linq.From(roleData.RoleTypes)
.ForEach(userData.Users)
.Where('x => x.ContentRole == "' + roleData.ContentRole + '"').Any();
console.log(results);
})
})
error with: 错误:
var results = linq.From(roleData.RoleTypes)
.ForEach(userData.Users)
.Where('x => x.ContentRole == "' + roleData.ContentRole + '"').Any();
error message: Uncaught Exception (js): Uncaught TypeError: Cannot call method 'Where' of undefined 错误消息: 未捕获的异常(js):未捕获的TypeError:无法调用未定义的方法“ Where”
.Where must be getting a bool predicate, but you are passing a string to it. 必须在哪里获取布尔谓词,但是您正在向其中传递字符串。 Try to change it to something like 尝试将其更改为类似
.Where(x => x.ContentRole == roleData.ContentRole);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.