原因 数据库中 code 字段 类型为 varchar 而实体的类型为 int  导致string 类型无法转化为int 类型而报错

        public int code { get; set; }

参考:https://www.cnblogs.com/Godric/p/10111594.html

Unable to cast object of type 'System.String' to type 'System.Int32'.的更多相关文章

  1. Unable to cast object of type 'System.Int32' to type 'System.String'.

    最近在研究.netcore,尝试把前后端完全分离.但是在写接口的时候,Post参数是FromBody的时候报错了 Microsoft.AspNetCore.Diagnostics.DeveloperE ...

  2. Unable to cast object of type 'System.Int32' to type 'System.Array'.

    x 入职了新公司.最近比较忙...一看博客...更新频率明显少了...罪过罪过... 新公司用ASP.NET MVC 遇上一个错误: Unable to cast object of type 'Sy ...

  3. golang 操作redis 错误:failed redigo: unexpected type for String, got type int64

    报错的代码: isExist,err := redis.String(conn.Do("EXISTS", key)) 这个操作返回的应该是bool类型,所有改成 isExist,e ...

  4. C#、.Net代码精简优化(空操作符(??)、as、string.IsNullOrEmpty() 、 string.IsNullOrWhiteSpace()、string.Equals()、System.IO.Path 的用法)

    一.空操作符(??)在程序中经常会遇到对字符串或是对象判断null的操作,如果为null则给空值或是一个指定的值.通常我们会这样来处理: .string name = value; if (name ...

  5. mono的Type.GetType(string)总是为空

    public partial class Index : System.Web.UI.Page { protected override void OnLoad(EventArgs e) { Resp ...

  6. System.TypeInitializationException: The type initializer for 'Mono.Unix.Native.Stdlib' threw an exception.

    08-31 17:02:03: ### DEBUG ##########################System.TypeInitializationException: The type ini ...

  7. 自己写的demo。List<HashMap<String,Object>>=new ArrayList<HashMap<String,Object>>

    package com.pb.collection; import java.util.ArrayList; import java.util.HashMap; import java.util.It ...

  8. Linq中字段数据类型转换问题(Linq to entity,LINQ to Entities 不识别方法"System.String ToString()"问题解决)

    1.在工作中碰到这样一个问题: 使用linq时,需要查询两个表,在这两张表中关联字段分别是int,和varchar()也就是string,在linq中对这两个字段进行关联, 如果强制类型转换两个不同类 ...

  9. Web Service接口返回泛型的问题(System.InvalidCastException: 无法将类型为“System.Collections.Generic.List`1[System.String]”的对象强制转换为类型“System.String[]”)

    在使用C#写Web Service时遇到了个很奇怪的问题.返回值的类型是泛型(我用的是类似List<string>)的接口,测试时发现总是报什么无法转换为对象的错误,百思不得其解. 后来在 ...

随机推荐

  1. QF中间件

    QF中间件使用说明          QF中间件是在2020年春节期间出现新型冠状病毒感染的肺炎疫情不敢外出,闲来无事编写的.编程是业余爱好,平时编程只会拖控件,中间件可能存在未知Bug,这个版本也只 ...

  2. gentoo emby-server

    最近想用 emby-server + kodi 打造家庭播放平台, 在 gentoo 上面先尝试安装配置 emby-server. 首先, 使用 megacoffee 这个 overlay, 这个上面 ...

  3. Android自定义View——QQ音乐中圆形旋转碟子

    1.在onMeasure中测量整个View的宽和高后,设置宽高 2.获取我们res的图片资源后,在ondraw方法中进行绘制圆形图片 3.通过Handler发送Runnable在主线程中更新UI,达到 ...

  4. day26(026-网络编程)

    ###26.02_网络编程(网络编程三要素之IP概述) IPv6:8组,每组4个16进制数. 1a2b:0000:aaaa:0000:0000:0000:aabb:1f2f ###26.03_网络编程 ...

  5. MarkDown简易教程+语法

    一.标题 一个#是一级,两个#是二级,最大六级 二.字体 1.加粗 要加粗的文字左右分别用两个*号包起来 2.斜体 要倾斜的文字左右分别用一个*号包起来 3.斜体加粗 要倾斜和加粗的文字左右分别用三个 ...

  6. redis(三)----连接池配置

    1. 目录结构: 2. 测试源码 package com.redis; import redis.clients.jedis.Jedis; import redis.clients.jedis.Jed ...

  7. Git--git log

    参考 https://www.cnblogs.com/bellkosmos/p/5923439.html https://www.cnblogs.com/mkl34367803/p/9219913.h ...

  8. 阿里云ECSlinux下php+mysql+apache

    https://yq.aliyun.com/articles/284131 安装apache https://yq.aliyun.com/articles/106387?spm=a2c4e.11153 ...

  9. POJ 2528 Mayor‘s poster 线段树+离散化

    给一块最大为10^8单位宽的墙面,贴poster,每个poster都会给出数据 a,b,表示该poster将从第a单位占据到b单位,新贴的poster会覆盖旧的,最多有10^4张poster,求最后贴 ...

  10. 吴裕雄--天生自然 JAVASCRIPT开发学习:DOM EventListener

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...