0
List<int> execFavoriteUsers = 
        (from exec in context.ExecutiveFavorites 
         where exec.ExecutiveUserID == model.UserID 
         select exec.ProfileUserID) 
        .ToList();
query = (from cast in query
        where execFavoriteUsers.Contains(cast.UserID) == false
        select cast);

但它在另一个系统中运行良好。如何修复此错误?

4

2 回答 2

0

尝试List<int?>代替List<int>.

或者如果您需要不可为空的整数:

List<int> execFavoriteUsers = 
        (from exec in context.ExecutiveFavorites 
         where exec.ExecutiveUserID == model.UserID 
         where exec.ProfileUserID.HasValue
         select exec.ProfileUserID.Value) 
        .ToList();
于 2012-06-06T10:11:51.417 回答
0

您确定 ProfileUserID 的类型是int? 它可能是 aNullable<int>或 along或 auint吗?

您总是可以删除显式声明并将其更改为var(在这种情况下不会发生冲突,因为它隐式推断类型)。

于 2012-06-06T10:09:19.520 回答