title: Can't update Tabled Mapped in Linq2Sql
body: <p>I'm having troubles right now, I can't update a table X in DBDataContext, so this is my snippet, by the way when I update just one table it works! But when I Insert and then update, it throws exception: "can't cast object from System.Int32 to System.String type"</p>
  
  <pre><code>{
              using (DBDataContext db = new DBDataContext())
              {
                  int codigo = Convert.ToInt32(lblNroInforme.Content);
                  int sucessfull = 0;
  
  
                  INFORMEMEDICO varInf = (from i in db.INFORMEMEDICOs
                                          where i.numeroinforme == codigo
                                          select i).SingleOrDefault();
  
  
                  if (varInf == null)
                  {
                      varInf = new INFORMEMEDICO();
                      varInf.codigoclase = Convert.ToInt32(lblCodigoClase.Content.ToString());
                      varInf.codigoestudio = lblCodigoEstudio.Content.ToString();
                      varInf.codigopaciente = Convert.ToInt32(lblCodigoPaciente.Content.ToString());
                      varInf.conclusion = GetText(rtbConclusion);
                      varInf.fechainforme = DateTime.Today;
                      varInf.firmauno = getJPGFromImageControl(firmaUno.Source as BitmapImage);
                      varInf.firmados = getJPGFromImageControl(firmaDos.Source as BitmapImage);
                      varInf.hallazgo = GetText(rtbHallazgo);
                      varInf.horainforme = Convert.ToDateTime(DateTime.Today.ToShortTimeString());
                      varInf.impreso = 0;
                      varInf.medicoinforma = cboTurnoMed.SelectedValue.ToString();
                      varInf.nombreinforme = txtNombreExamen.Text;
                      varInf.numeroinforme = Convert.ToInt32(lblNroInforme.Content.ToString());
                      varInf.tecnica = GetText(rtbTecnica);
                      varInf.turnosocio = lblTurnoMedico.Content.ToString();
  
                      try
                      {
                          db.INFORMEMEDICOs.InsertOnSubmit(varInf);
                          db.SubmitChanges();
                          sucessfull = 1;
                      }
                      catch (Exception ex)
                      {
                          MessageBox.Show("Error : " + ex.Message);
                      }
                      if (sucessfull==1)
                      {
                          EXAMENXATENCION varExA = (from ea in db.EXAMENXATENCIONs
                                                    where ea.codigo == codigo
                                                    select ea).SingleOrDefault();
                          varExA.estadoestudio = 'I';
                          db.SubmitChanges();
                      }
  
                  }
  
              }
  
          }
  </code></pre>
  
  <p>I'm getting this stack from debugger when I perform update : </p>
  
  <pre><code>en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2&amp; k)
     en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2&amp; k)
     en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2&amp; k)
     en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2&amp; k)
     en System.Data.Linq.IdentityManager.StandardIdentityManager.IdentityCache`2.Find(Object[] keyValues)
     en System.Data.Linq.IdentityManager.StandardIdentityManager.Find(MetaType type, Object[] keyValues)
     en System.Data.Linq.CommonDataServices.GetCachedObject(MetaType type, Object[] keyValues)
     en System.Data.Linq.ChangeProcessor.GetOtherItem(MetaAssociation assoc, Object instance)
     en System.Data.Linq.ChangeProcessor.BuildEdgeMaps()
     en System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
     en System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
     en System.Data.Linq.DataContext.SubmitChanges()
     en Demo.View.InformeMedico.btnGuardar_Click(Object sender, RoutedEventArgs e) en D:\cs_InformeMedico\app\InformeMedico.xaml.cs:línea 430
  </code></pre>