有一個實體類有如下定義:...public Guid? guidUserId;public int userId;
...我現在的到了 一個List guidUserId 類型,我想要通過這個獲取userId (這個和guidUserID是一一對應的)我試過了以下的方法: _userInfo.Where(q => guidUserId.Contains(q.guidUserId))
.Select(q => q.userId);
//或者
from s in _userInfo where s.guidUserId !=null && ids.Contains(s.guidUserId.Value) select s.UserID);上面兩種方法一律失敗,在SQL Profile 中監控,發現進行了全表查詢。問題出在 guidUserId 為可空的。請問在EF Core 中如何查詢可空變量的值?
- 2 回答
- 0 關注
- 1159 瀏覽
添加回答
舉報
0/150
提交
取消