繁体   English   中英

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

[英]Uncaught TypeError: Cannot call method 'Where' of undefined

我不确定造成此错误的原因是什么,但我试图使用linq查询(如语句)返回结果以循环浏览职位列表,然后进行另一个循环以获取每个职位的所有用户。

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);
})
})

错误:

var results = linq.From(roleData.RoleTypes)
                                .ForEach(userData.Users)
                                .Where('x => x.ContentRole == "' + roleData.ContentRole + '"').Any();

错误消息: 未捕获的异常(js):未捕获的TypeError:无法调用未定义的方法“ Where”

必须在哪里获取布尔谓词,但是您正在向其中传递字符串。 尝试将其更改为类似

 .Where(x => x.ContentRole == roleData.ContentRole);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM