我試圖創建一個LINQ來獲取Users表中存在的Personnel表中的記錄。這裏是我目前正在使用的教程:Convert the Results of a LINQ Query to an Array。將LINQ與模型轉換爲數組
然而,當我嘗試實施它在我的代碼我有一個錯誤:'UserModel[]' does not contain a definition for 'Contains' and the best extension method overload 'Queryable.Contains<string>(IQueryable<string>, string)' requires a receiver of type 'IQueryable<string>'
var users = from u in db.USR_MSTR select new UserModel { emp_id = u.EMP_ID };
UserModel[] userList = users.ToArray();
var matches = from p in db.PERSONNEL_MSTR
where userList.Contains(p.EMP_ID) //userList is generating the error above
select p;
謝謝您的時間,先生,我喜歡它,它是如何的非常簡單。我也會試試這個,並會與其他答案一起檢查,看看我的整個項目更方便。 –