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

时间:2015-06-16 10:47:24   收藏:0   阅读:1023

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);
            }

原文:http://www.cnblogs.com/shoushou/p/4580085.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!