【问题标题】:The type 'Edm.Int32' of the member 'SessionId' in the conceptual side type 'Converter.Session' does not match with the type 'System概念端类型“Converter.Session”中成员“SessionId”的类型“Edm.Int32”与“系统”类型不匹配
【发布时间】:2017-03-18 08:31:30
【问题描述】:

当我登录我的简单应用程序时。就会出现这个错误。

概念端类型“Converter.Session”中成员“SessionId”的类型“Edm.Int32”与对象端成员“SessionId”的类型“System.Decimal”不匹配输入

在我的错误行代码下方

List<User> users = context.Users.ToList<User>();

吹出我的完整代码

private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
    InputBox("User Name", "Please enter User ID", ref UserName);

    QuestionId = 0;
    Boolean UserExsits = false;
    context = new ConversionGameDBContainer();
    List<User> users = context.Users.ToList<User>();// this is error line
    foreach (User i in users)
    {
        if (i.UserId.ToString().Trim().Equals(UserName.Trim()))
        {
            UserExsits = true;
            UserLogged = true;
            MessageBox.Show("Hello " + UserName + "!!! you are back, Enjoy the game");
            break;
        }
    }
    if (!UserExsits)
    {
        User u = new User();

        u.UserId = UserName;
        context.Users.Add(u);

        context.SaveChanges();
        MessageBox.Show("User Id " + UserName + " Created and enjoy the game");
        UserLogged = true;
    }

    ConvertorButton.Enabled = false;
    if (UserLogged)
    {
        DateTime d = DateTime.Now;
        session = new Session();
        session.StartTime = d;
        session.UserId = UserName;
        context.Sessions.Add(session);

        context.SaveChanges();
        context.Entry(session).GetDatabaseValues();

        SessionId = session.SessionId;
    }

    if (f == null)
    {
        f = new HistoryResult();
    }

    PlayConversionGame.UserName = UserName;
    f.Show();
    String Output = "";
    context = new ConversionGameDBContainer();
}

【问题讨论】:

    标签: c# c++ visual-studio c#-4.0 c#-3.0


    【解决方案1】:

    我知道这个问题有点老了,但是在遇到相同的错误消息时我偶然发现了它。

    删除 bin 和 object 文件夹,然后重新运行项目,为我解决了问题。

    另请参阅此问题(编辑部分 OP): How to solve the following MappingException

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多