当前位置:首页 > Windows程序 > 正文

MVC c# 没有为类型“System.Nullable`1[System.Int32]”和“System.Int32”

2021-05-25 Windows程序

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

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/70853.html