解决 No coercion operator is defined between types 'System.Int16' and 'System.Boolean'

Linq Any转换失败:

var isExist = db.MyDbTable.Any(o => o.Id == id);

//throw No coercion operator is defined between types 'System.Int16' and 'System.Boolean',

          要改成

          var isExist = db.MyDbTable.FirstOrDefault(o => o.Id == id) != null;

亲测 有效

你可能感兴趣的:(解决 No coercion operator is defined between types 'System.Int16' and 'System.Boolean')