简体   繁体   English

未捕获的TypeError:无法调用未定义的方法“ Where”

[英]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.

相关问题 未捕获的TypeError:无法调用未定义的jQuery easydropdown的方法“ removeClass” - Uncaught TypeError: Cannot call method 'removeClass' of undefined jQuery easydropdown 未捕获的类型错误:无法读取未定义的属性“msie” - Uncaught TypeError: Cannot read property 'msie' of undefined 未捕获的TypeError:无法读取未定义的属性'addIceCandidate' - Uncaught TypeError: Cannot read property 'addIceCandidate' of undefined ......未捕获的类型错误:无法读取未定义的属性“登录” - ......Uncaught TypeError: Cannot read property 'login' of undefined 未捕获的TypeError:无法读取未定义的属性'setData' - Uncaught TypeError: Cannot read property 'setData' of undefined 未捕获的TypeError:无法读取未定义的属性'enqueueSetState' - Uncaught TypeError: Cannot read property 'enqueueSetState' of undefined 未捕获的类型错误:无法读取未定义的属性“替换” - Uncaught TypeError: Cannot read property 'replace' of undefined 未捕获的TypeError:undefined不是函数 - Uncaught TypeError: undefined is not a function 未捕获的类型错误:无法读取未定义的属性“PRM_ServerError” - Uncaught TypeError: Cannot read property 'PRM_ServerError' of undefined jqgrid未被捕获的TypeError:无法读取未定义的属性“ stype” - jqgrid Uncaught TypeError: Cannot read property 'stype' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM