簡體   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