我想获取CategoryId
is的所有行null
。我写了下面的代码,但它给了我错误
" 运算符 ' == ' 不能应用于 'int?' 类型的操作数 和 System.DBNull
public Nullable<Int32> CategoryId { get; set; }
Game objGame;
var query = (from gametypebygametype in db.GameByGameTypes.Where(x => x.CategoryId == DBNull.Value)
join game in db.Games
on gametypebygametype.GameId equals game.GameId into joined
from game in joined.DefaultIfEmpty()
select new
{
game.GameId,
game.GameName
}
).Distinct();
List<Game> objlistGame = new List<Game>();
foreach (var item_temp in query)
{
objGame = new Game();
objGame.GameId = item_temp.GameId;
objGame.GameName = item_temp.GameName;
objlistGame.Add(objGame);
}