MVC c# 没有为类型“System.Nullable`1[System.Int32]”和“System.Int32”定义二进制运算符 Equal。

Entity framework 运用过程中,条件查询时会出现  MVC c# 没有为类型“System.Nullable`1[System.Int32]”和“System.Int32”定义二进制运算符 Equal。

 

处理方法:int类型进行连接是, 非空和非零的前提下才进行Equal,所以尝试转换成int成功就可以处理掉这个异常。

       int UserId ;
           if (int.TryParse(Request["UserId"], out UserId))
            {
              
                where.Equal("UserId", UserId);
            }

posted on 2015-06-16 10:26  獸獸  阅读(4806)  评论(0编辑  收藏  举报

导航