zoukankan      html  css  js  c++  java
  • Unable to cast object of type 'System.Int32' to type 'System.String'.

    关键错误点Unable to cast object of type 'System.Int32' to type 'System.String'.提示是无法将“System.Int32”的对象强制转换为“System.String”。于是我就找了所有使用Int的地方,终于发现

    /// <summary>
         /// ID
         /// </summary>
         [Key]
         [StringLength(20)]
     [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
     public override int ID { get; set; }

    在一个基类中有个Int类型的ID,不小心加上了StringLength属性。int类型是不能添加StringLength属性的,去掉之后就可以正常访问了。

  • 相关阅读:
    C# 小算法1
    函数 y=x^x的分析
    随机数
    对拍
    Cube Stack
    Permutation
    一笔画问题
    康托展开&&康托逆展开
    待完成
    小错误 17/8/10
  • 原文地址:https://www.cnblogs.com/djd66/p/14808269.html
Copyright © 2011-2022 走看看