LINQ to SQL,db.SubmitChanges() 失败

发布于 2024-07-13 23:18:44 字数 25440 浏览 14 评论 0原文

当我尝试更新时出现异常,插入工作完美......所以这是: System.Data.Linq.dll 中发生“System.InvalidCastException”类型的第一次机会异常 另一个提示...可以先插入一个表,然后更新另一个表,最后在同一代码块中提交更改()? 我还评论了 InsertOnSubmit(); 我重建 dbml(删除并再次创建)更改了名称、上下文等。 代码 :

using (DB db = new DB())
            {
                //db.ObjectTrackingEnabled = false;
                INFORMEMEDICO varInf = (from i in db.INFORMEMEDICOs
                                        where i.numeroinforme == codigo
                                        select i).SingleOrDefault();

                EXAMENXATENCION varExA = (from ea in db.EXAMENXATENCIONs
                                          where ea.codigo == codigo
                                          select ea).Single();

                if (varInf == null)
                {
                    varInf = new INFORMEMEDICO();
                    varInf.firmauno = getJPGFromImageControl(firmaUno.Source as BitmapImage);
                    varInf.firmados = getJPGFromImageControl(firmaDos.Source as BitmapImage);
                    varInf.tecnica = GetText(rtbTec);
                    varExA.estadoestudio = 'I';                    
                    try
                    {
                        db.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);
                        //db.INFORMEMEDICOs.InsertOnSubmit(varInf);
                        MessageBox.Show("Informe Medico Registrado con exito: " + "\n" + "Nro Informe :" + codigo);
                    }
                    catch (Exception ex)
                    {
                        sucessfull = 0;
                        MessageBox.Show("Error en Registro : " + ex.Message);
                    }



                }

Stack :

System.InvalidCastException was caught
  Message="No se puede convertir un objeto de tipo 'System.Int32' al tipo 'System.String'."
  Source="System.Data.Linq"
  StackTrace:
       en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2& k)
       en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2& k)
       en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2& k)
       en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2& 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 433
  InnerException:

感谢您的持续支持

XML :

<?xml version="1.0" encoding="utf-8"?>
<ordesignerObjectsDiagram dslVersion="1.0.0.0" absoluteBounds="0, 0, 11.625, 14" name="DataClasses1">
  <DataContextMoniker Name="/DB" />
  <nestedChildShapes>
    <classShape Id="578a0699-bcf4-45c5-9bec-2beb667a6a06" absoluteBounds="5.75, 1.25, 2, 3.23266845703125">
      <DataClassMoniker Name="/DB/EXAMENXATENCION" />
      <nestedChildShapes>
        <elementListCompartment Id="10f26c82-1f06-45d2-9488-da3d7d92e231" absoluteBounds="5.7650000000000006, 1.71, 1.9700000000000002, 2.67266845703125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <classShape Id="1f3a6a96-bcc1-41c3-8d57-b9987a3cdec1" absoluteBounds="2.625, 2.875, 2, 1.4248478190104168">
      <DataClassMoniker Name="/DB/ESTUDIO" />
      <nestedChildShapes>
        <elementListCompartment Id="86092ab5-554b-402d-a8cf-938b89f4473e" absoluteBounds="2.64, 3.335, 1.9700000000000002, 0.86484781901041674" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(4.625 : 3.58742390950521); (5.75 : 3.58742390950521)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/ESTUDIO/ESTUDIO_EXAMENXATENCION" />
      <nodes>
        <classShapeMoniker Id="1f3a6a96-bcc1-41c3-8d57-b9987a3cdec1" />
        <classShapeMoniker Id="578a0699-bcf4-45c5-9bec-2beb667a6a06" />
      </nodes>
    </associationConnector>
    <classShape Id="e4ab888d-5eb4-4b81-a562-baa1ff7393f8" absoluteBounds="7.875, 5.625, 2, 2.5752791341145831">
      <DataClassMoniker Name="/DB/PACIENTE" />
      <nestedChildShapes>
        <elementListCompartment Id="239b98aa-995d-458c-b0e6-4211e108c99d" absoluteBounds="7.8900000000000006, 6.085, 1.9700000000000002, 2.015279134114583" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <classShape Id="516b8633-e8ba-43f7-bf23-8c18e055e9b4" absoluteBounds="1.625, 5, 2, 2.9039737955729166">
      <DataClassMoniker Name="/DB/ATENCION" />
      <nestedChildShapes>
        <elementListCompartment Id="c3ec622f-93e5-4418-bb4d-7903b46ac639" absoluteBounds="1.6400000000000001, 5.46, 1.9700000000000002, 2.3439737955729165" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(3.625 : 6.24307135546875); (4.07291666666667 : 6.24307135546875 : JumpStart); (4.23958333333333 : 6.24307135546875 : JumpEnd); (7.21875 : 6.24307135546875); (7.21875 : 4.48266845703125)]" manuallyRouted="true" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/ATENCION/ATENCION_EXAMENXATENCION" />
      <nodes>
        <classShapeMoniker Id="516b8633-e8ba-43f7-bf23-8c18e055e9b4" />
        <classShapeMoniker Id="578a0699-bcf4-45c5-9bec-2beb667a6a06" />
      </nodes>
    </associationConnector>
    <associationConnector edgePoints="[(7.875 : 7.5486477109375); (4.23958333333333 : 7.5486477109375 : JumpStart); (4.07291666666667 : 7.5486477109375 : JumpEnd); (3.625 : 7.5486477109375)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/PACIENTE/PACIENTE_ATENCION" />
      <nodes>
        <classShapeMoniker Id="e4ab888d-5eb4-4b81-a562-baa1ff7393f8" />
        <classShapeMoniker Id="516b8633-e8ba-43f7-bf23-8c18e055e9b4" />
      </nodes>
    </associationConnector>
    <classShape Id="f479daef-94e3-451a-b060-f4644304ec8c" absoluteBounds="0.5, 0.5, 2, 2.4109318033854166">
      <DataClassMoniker Name="/DB/MEDICOEXTERNO" />
      <nestedChildShapes>
        <elementListCompartment Id="964d649c-c39e-48c6-b130-215c40080462" absoluteBounds="0.515, 0.96, 1.9700000000000002, 1.8509318033854165" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(2.0625 : 2.91093180338542); (2.0625 : 5)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/MEDICOEXTERNO/MEDICOEXTERNO_ATENCION" />
      <nodes>
        <classShapeMoniker Id="f479daef-94e3-451a-b060-f4644304ec8c" />
        <classShapeMoniker Id="516b8633-e8ba-43f7-bf23-8c18e055e9b4" />
      </nodes>
    </associationConnector>
    <classShape Id="5ce0ebb2-391e-46de-b85c-c6a50434ea12" absoluteBounds="3.125, 0.5, 2, 1.26050048828125">
      <DataClassMoniker Name="/DB/FIRMA" />
      <nestedChildShapes>
        <elementListCompartment Id="a21918ee-6f48-470d-9f0e-a9160faab27e" absoluteBounds="3.1399999999999997, 0.96, 1.9700000000000002, 0.70050048828125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <classShape Id="8080f6a7-cd0f-4e38-a667-8aa34c40969e" absoluteBounds="5.375, 9, 2, 1.9178898111979166">
      <DataClassMoniker Name="/DB/PLANTILLA" />
      <nestedChildShapes>
        <elementListCompartment Id="b6606488-da97-4a5c-9204-1c1874f1fb29" absoluteBounds="5.39, 9.46, 1.9700000000000002, 1.3578898111979165" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <classShape Id="2ecb0a31-9312-4243-9d5a-dcecc886146c" absoluteBounds="1.375, 8.875, 2, 1.75354248046875">
      <DataClassMoniker Name="/DB/EQUIPO" />
      <nestedChildShapes>
        <elementListCompartment Id="b72b559d-fea0-4615-a2ac-08b4dc715230" absoluteBounds="1.3900000000000001, 9.335, 1.9700000000000002, 1.19354248046875" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(3.375 : 8.90625); (4.07291666666667 : 8.90625 : JumpStart); (4.23958333333333 : 8.90625 : JumpEnd); (7.59375 : 8.90625); (7.59375 : 4.48266845703125)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/EQUIPO/EQUIPO_EXAMENXATENCION" />
      <nodes>
        <classShapeMoniker Id="2ecb0a31-9312-4243-9d5a-dcecc886146c" />
        <classShapeMoniker Id="578a0699-bcf4-45c5-9bec-2beb667a6a06" />
      </nodes>
    </associationConnector>
    <classShape Id="8a332fc0-58f9-4d58-ae99-d84b9ef09d01" absoluteBounds="9.375, 10.5, 2, 3.23266845703125">
      <DataClassMoniker Name="/DB/INFORMEMEDICO" />
      <nestedChildShapes>
        <elementListCompartment Id="2696f44c-b32e-4a93-b012-c19292012a86" absoluteBounds="9.39, 10.96, 1.9700000000000002, 2.67266845703125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(9.625 : 8.20027913411458); (9.625 : 10.5)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/PACIENTE/PACIENTE_INFORMEMEDICO" />
      <nodes>
        <classShapeMoniker Id="e4ab888d-5eb4-4b81-a562-baa1ff7393f8" />
        <classShapeMoniker Id="8a332fc0-58f9-4d58-ae99-d84b9ef09d01" />
      </nodes>
    </associationConnector>
    <associationConnector edgePoints="[(4.15625 : 4.29984781901042); (4.15625 : 12.3565291341146); (9.375 : 12.3565291341146)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/ESTUDIO/ESTUDIO_INFORMEMEDICO" />
      <nodes>
        <classShapeMoniker Id="1f3a6a96-bcc1-41c3-8d57-b9987a3cdec1" />
        <classShapeMoniker Id="8a332fc0-58f9-4d58-ae99-d84b9ef09d01" />
      </nodes>
    </associationConnector>
  </nestedChildShapes>
</ordesignerObjectsDiagram>

XML : 哦哦 :)

<?xml version="1.0" encoding="utf-8"?>
<Database Name="DATABASEGENERAL" EntityNamespace="Demo.View.Data" ContextNamespace="Demo.View" Class="DB" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
  <Connection Mode="AppSettings" ConnectionString="Data Source=192.168.0.3;Initial Catalog=DATABASEGENERAL;Integrated Security=True" SettingsObjectName="SRIMedico.Properties.Settings" SettingsPropertyName="DATABASEGENERALConnectionString1" Provider="System.Data.SqlClient" />
  <Table Name="dbo.EXAMENXATENCION" Member="EXAMENXATENCIONs">
    <Type Name="EXAMENXATENCION">
      <Column Name="codigo" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
      <Column Name="numeroatencion" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigopaciente" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="numerocita" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigocompaniaseguro" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="ruc" Type="System.String" DbType="Char(11) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoequipo" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="horaatencion" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="codigoestudio" Type="System.String" DbType="Char(12) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoclase" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigomodalidad" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigounidad" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="estadoestudio" Type="System.Char" DbType="Char(1) NOT NULL" CanBeNull="false" />
      <Column Name="prioridad" Type="System.String" DbType="VarChar(20) NOT NULL" CanBeNull="false" />
      <Column Name="turnomedico" Type="System.String" DbType="Char(5)" CanBeNull="true" />
      <Association Name="ATENCION_EXAMENXATENCION" Member="ATENCION" ThisKey="numeroatencion,codigopaciente,codigomodalidad,codigounidad,codigocompaniaseguro,ruc,numerocita" OtherKey="numeroatencion,codigopaciente,codigomodalidad,codigounidad,codigocompaniaseguro,ruc,numerocita" Type="ATENCION" IsForeignKey="true" />
      <Association Name="EQUIPO_EXAMENXATENCION" Member="EQUIPO" ThisKey="codigoequipo" OtherKey="codigoequipo" Type="EQUIPO" IsForeignKey="true" />
      <Association Name="ESTUDIO_EXAMENXATENCION" Member="ESTUDIO" ThisKey="codigoestudio,codigoclase" OtherKey="codigoestudio,codigoclase" Type="ESTUDIO" IsForeignKey="true" />
    </Type>
  </Table>
  <Table Name="dbo.ATENCION" Member="ATENCIONs">
    <Type Name="ATENCION">
      <Column Name="fechayhora" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="numeroatencion" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
      <Column Name="codigopaciente" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="cmp" Type="System.String" DbType="Char(6) NOT NULL" CanBeNull="false" />
      <Column Name="codigocompaniaseguro" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="ruc" Type="System.String" DbType="Char(11) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="numerocita" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigomodalidad" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigounidad" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="peso" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
      <Column Name="talla" Type="System.Single" DbType="Real NOT NULL" CanBeNull="false" />
      <Column Name="edad" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
      <Column Name="codigousuario" Type="System.String" DbType="VarChar(20) NOT NULL" CanBeNull="false" />
      <Association Name="ATENCION_EXAMENXATENCION" Member="EXAMENXATENCIONs" ThisKey="numeroatencion,codigopaciente,codigomodalidad,codigounidad,codigocompaniaseguro,ruc,numerocita" OtherKey="numeroatencion,codigopaciente,codigomodalidad,codigounidad,codigocompaniaseguro,ruc,numerocita" Type="EXAMENXATENCION" />
      <Association Name="PACIENTE_ATENCION" Member="PACIENTE" ThisKey="codigopaciente" OtherKey="codigopaciente" Type="PACIENTE" IsForeignKey="true" />
      <Association Name="MEDICOEXTERNO_ATENCION" Member="MEDICOEXTERNO" ThisKey="cmp" OtherKey="cmp" Type="MEDICOEXTERNO" IsForeignKey="true" />
    </Type>
  </Table>
  <Table Name="dbo.INFORMEMEDICO" Member="INFORMEMEDICOs">
    <Type Name="INFORMEMEDICO">
      <Column Name="numeroinforme" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoestudio" Type="System.String" DbType="Char(12) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="turnosocio" Type="System.String" DbType="Char(5) NOT NULL" CanBeNull="false" />
      <Column Name="fechainforme" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="horainforme" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="tecnica" Type="System.String" DbType="VarChar(3000) NOT NULL" CanBeNull="false" />
      <Column Name="hallazgo" Type="System.String" DbType="VarChar(5000) NOT NULL" CanBeNull="false" />
      <Column Name="conclusion" Type="System.String" DbType="VarChar(3000) NOT NULL" CanBeNull="false" />
      <Column Name="impreso" Type="System.Boolean" DbType="Bit NOT NULL" CanBeNull="false" />
      <Column Name="codigoclase" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigopaciente" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="medicoinforma" Type="System.String" DbType="Char(5) NOT NULL" CanBeNull="false" />
      <Column Name="firmados" Type="System.Data.Linq.Binary" DbType="Image" CanBeNull="true" UpdateCheck="Never" />
      <Column Name="firmauno" Type="System.Data.Linq.Binary" DbType="Image" CanBeNull="true" UpdateCheck="Never" />
      <Column Name="nombreinforme" Type="System.String" DbType="VarChar(150) NOT NULL" CanBeNull="false" />
      <Association Name="ESTUDIO_INFORMEMEDICO" Member="ESTUDIO" ThisKey="codigoestudio,codigoclase" OtherKey="codigoestudio,codigoclase" Type="ESTUDIO" IsForeignKey="true" />
      <Association Name="PACIENTE_INFORMEMEDICO" Member="PACIENTE" ThisKey="codigopaciente" OtherKey="codigopaciente" Type="PACIENTE" IsForeignKey="true" />
    </Type>
  </Table>
  <Table Name="dbo.EQUIPO" Member="EQUIPOs">
    <Type Name="EQUIPO">
      <Column Name="fechaadquirio" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="intensidad" Type="System.Single" DbType="Real NOT NULL" CanBeNull="false" />
      <Column Name="modelo" Type="System.String" DbType="VarChar(40)" CanBeNull="true" />
      <Column Name="marca" Type="System.String" DbType="VarChar(40) NOT NULL" CanBeNull="false" />
      <Column Name="nombreequipo" Type="System.String" DbType="VarChar(35) NOT NULL" CanBeNull="false" />
      <Column Name="codigoequipo" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Association Name="EQUIPO_EXAMENXATENCION" Member="EXAMENXATENCIONs" ThisKey="codigoequipo" OtherKey="codigoequipo" Type="EXAMENXATENCION" />
    </Type>
  </Table>
  <Table Name="dbo.ESTUDIO" Member="ESTUDIOs">
    <Type Name="ESTUDIO">
      <Column Name="nombreestudio" Type="System.String" DbType="VarChar(100) NOT NULL" CanBeNull="false" />
      <Column Name="codigoestudio" Type="System.String" DbType="Char(12) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoclase" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="indicacion" Type="System.String" DbType="VarChar(500)" CanBeNull="true" />
      <Association Name="ESTUDIO_EXAMENXATENCION" Member="EXAMENXATENCIONs" ThisKey="codigoestudio,codigoclase" OtherKey="codigoestudio,codigoclase" Type="EXAMENXATENCION" />
      <Association Name="ESTUDIO_INFORMEMEDICO" Member="INFORMEMEDICOs" ThisKey="codigoestudio,codigoclase" OtherKey="codigoestudio,codigoclase" Type="INFORMEMEDICO" />
    </Type>
  </Table>
  <Table Name="dbo.PACIENTE" Member="PACIENTEs">
    <Type Name="PACIENTE">
      <Column Name="nacionalidad" Type="System.String" DbType="VarChar(20) NOT NULL" CanBeNull="false" />
      <Column Name="direccion" Type="System.String" DbType="VarChar(80)" CanBeNull="true" />
      <Column Name="email" Type="System.String" DbType="VarChar(60)" CanBeNull="true" />
      <Column Name="celular" Type="System.String" DbType="VarChar(20)" CanBeNull="true" />
      <Column Name="telefono" Type="System.String" DbType="VarChar(20) NOT NULL" CanBeNull="false" />
      <Column Name="fechanace" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="sexo" Type="System.Char" DbType="Char(1) NOT NULL" CanBeNull="false" />
      <Column Name="nombres" Type="System.String" DbType="VarChar(35) NOT NULL" CanBeNull="false" />
      <Column Name="apellidos" Type="System.String" DbType="VarChar(45) NOT NULL" CanBeNull="false" />
      <Column Name="dni" Type="System.String" DbType="VarChar(20)" CanBeNull="true" />
      <Column Name="codigopaciente" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Association Name="PACIENTE_ATENCION" Member="ATENCIONs" ThisKey="codigopaciente" OtherKey="codigopaciente" Type="ATENCION" />
      <Association Name="PACIENTE_INFORMEMEDICO" Member="INFORMEMEDICOs" ThisKey="codigopaciente" OtherKey="codigopaciente" Type="INFORMEMEDICO" />
    </Type>
  </Table>
  <Table Name="dbo.MEDICOEXTERNO" Member="MEDICOEXTERNOs">
    <Type Name="MEDICOEXTERNO">
      <Column Name="cmp" Type="System.String" DbType="Char(6) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="apellidos" Type="System.String" DbType="VarChar(45) NOT NULL" CanBeNull="false" />
      <Column Name="nombres" Type="System.String" DbType="VarChar(35) NOT NULL" CanBeNull="false" />
      <Column Name="telefono" Type="System.String" DbType="VarChar(20)" CanBeNull="true" />
      <Column Name="direccion" Type="System.String" DbType="VarChar(80)" CanBeNull="true" />
      <Column Name="email" Type="System.String" DbType="VarChar(60)" CanBeNull="true" />
      <Column Name="fechanacio" Type="System.DateTime" DbType="DateTime" CanBeNull="true" />
      <Column Name="codigoespecialidad" Type="System.Int32" DbType="Int" CanBeNull="true" />
      <Column Name="activo" Type="System.Boolean" DbType="Bit NOT NULL" CanBeNull="false" />
      <Column Name="celular" Type="System.String" DbType="VarChar(20)" CanBeNull="true" />
      <Association Name="MEDICOEXTERNO_ATENCION" Member="ATENCIONs" ThisKey="cmp" OtherKey="cmp" Type="ATENCION" />
    </Type>
  </Table>
  <Table Name="dbo.PLANTILLA" Member="PLANTILLAs">
    <Type Name="PLANTILLA">
      <Column Name="codigoplantilla" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoequipo" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
      <Column Name="codigoestudio" Type="System.String" DbType="Char(12) NOT NULL" CanBeNull="false" />
      <Column Name="tituloplantilla" Type="System.String" DbType="VarChar(150) NOT NULL" CanBeNull="false" />
      <Column Name="tecnica" Type="System.String" DbType="VarChar(3000) NOT NULL" CanBeNull="false" />
      <Column Name="hallazgo" Type="System.String" DbType="VarChar(5000) NOT NULL" CanBeNull="false" />
      <Column Name="conclusion" Type="System.String" DbType="VarChar(3000) NOT NULL" CanBeNull="false" />
    </Type>
  </Table>
  <Table Name="dbo.FIRMA" Member="FIRMAs">
    <Type Name="FIRMA">
      <Column Name="codigofirma" Type="System.String" DbType="VarChar(20) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="siglas" Type="System.String" DbType="Char(5) NOT NULL" CanBeNull="false" />
      <Column Name="imagen" Type="System.Data.Linq.Binary" DbType="Image NOT NULL" CanBeNull="false" UpdateCheck="Never" />
    </Type>
  </Table>
</Database>

Im getting an Exception when I try updating, Insert works perfectly.. so this is:
A first chance exception of type 'System.InvalidCastException' occurred in System.Data.Linq.dll
Another cue... is possible to insert in one table first and then update another table and finally submitchanges() all in same code-block?
I also comment InsertOnSubmit(); and I Rebuild dbml (drop and create again) changed name, context etc..
Code :

using (DB db = new DB())
            {
                //db.ObjectTrackingEnabled = false;
                INFORMEMEDICO varInf = (from i in db.INFORMEMEDICOs
                                        where i.numeroinforme == codigo
                                        select i).SingleOrDefault();

                EXAMENXATENCION varExA = (from ea in db.EXAMENXATENCIONs
                                          where ea.codigo == codigo
                                          select ea).Single();

                if (varInf == null)
                {
                    varInf = new INFORMEMEDICO();
                    varInf.firmauno = getJPGFromImageControl(firmaUno.Source as BitmapImage);
                    varInf.firmados = getJPGFromImageControl(firmaDos.Source as BitmapImage);
                    varInf.tecnica = GetText(rtbTec);
                    varExA.estadoestudio = 'I';                    
                    try
                    {
                        db.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);
                        //db.INFORMEMEDICOs.InsertOnSubmit(varInf);
                        MessageBox.Show("Informe Medico Registrado con exito: " + "\n" + "Nro Informe :" + codigo);
                    }
                    catch (Exception ex)
                    {
                        sucessfull = 0;
                        MessageBox.Show("Error en Registro : " + ex.Message);
                    }



                }

Stack :

System.InvalidCastException was caught
  Message="No se puede convertir un objeto de tipo 'System.Int32' al tipo 'System.String'."
  Source="System.Data.Linq"
  StackTrace:
       en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2& k)
       en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2& k)
       en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2& k)
       en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2& 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 433
  InnerException:

Thanks for yours continuos support

XML :

<?xml version="1.0" encoding="utf-8"?>
<ordesignerObjectsDiagram dslVersion="1.0.0.0" absoluteBounds="0, 0, 11.625, 14" name="DataClasses1">
  <DataContextMoniker Name="/DB" />
  <nestedChildShapes>
    <classShape Id="578a0699-bcf4-45c5-9bec-2beb667a6a06" absoluteBounds="5.75, 1.25, 2, 3.23266845703125">
      <DataClassMoniker Name="/DB/EXAMENXATENCION" />
      <nestedChildShapes>
        <elementListCompartment Id="10f26c82-1f06-45d2-9488-da3d7d92e231" absoluteBounds="5.7650000000000006, 1.71, 1.9700000000000002, 2.67266845703125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <classShape Id="1f3a6a96-bcc1-41c3-8d57-b9987a3cdec1" absoluteBounds="2.625, 2.875, 2, 1.4248478190104168">
      <DataClassMoniker Name="/DB/ESTUDIO" />
      <nestedChildShapes>
        <elementListCompartment Id="86092ab5-554b-402d-a8cf-938b89f4473e" absoluteBounds="2.64, 3.335, 1.9700000000000002, 0.86484781901041674" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(4.625 : 3.58742390950521); (5.75 : 3.58742390950521)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/ESTUDIO/ESTUDIO_EXAMENXATENCION" />
      <nodes>
        <classShapeMoniker Id="1f3a6a96-bcc1-41c3-8d57-b9987a3cdec1" />
        <classShapeMoniker Id="578a0699-bcf4-45c5-9bec-2beb667a6a06" />
      </nodes>
    </associationConnector>
    <classShape Id="e4ab888d-5eb4-4b81-a562-baa1ff7393f8" absoluteBounds="7.875, 5.625, 2, 2.5752791341145831">
      <DataClassMoniker Name="/DB/PACIENTE" />
      <nestedChildShapes>
        <elementListCompartment Id="239b98aa-995d-458c-b0e6-4211e108c99d" absoluteBounds="7.8900000000000006, 6.085, 1.9700000000000002, 2.015279134114583" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <classShape Id="516b8633-e8ba-43f7-bf23-8c18e055e9b4" absoluteBounds="1.625, 5, 2, 2.9039737955729166">
      <DataClassMoniker Name="/DB/ATENCION" />
      <nestedChildShapes>
        <elementListCompartment Id="c3ec622f-93e5-4418-bb4d-7903b46ac639" absoluteBounds="1.6400000000000001, 5.46, 1.9700000000000002, 2.3439737955729165" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(3.625 : 6.24307135546875); (4.07291666666667 : 6.24307135546875 : JumpStart); (4.23958333333333 : 6.24307135546875 : JumpEnd); (7.21875 : 6.24307135546875); (7.21875 : 4.48266845703125)]" manuallyRouted="true" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/ATENCION/ATENCION_EXAMENXATENCION" />
      <nodes>
        <classShapeMoniker Id="516b8633-e8ba-43f7-bf23-8c18e055e9b4" />
        <classShapeMoniker Id="578a0699-bcf4-45c5-9bec-2beb667a6a06" />
      </nodes>
    </associationConnector>
    <associationConnector edgePoints="[(7.875 : 7.5486477109375); (4.23958333333333 : 7.5486477109375 : JumpStart); (4.07291666666667 : 7.5486477109375 : JumpEnd); (3.625 : 7.5486477109375)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/PACIENTE/PACIENTE_ATENCION" />
      <nodes>
        <classShapeMoniker Id="e4ab888d-5eb4-4b81-a562-baa1ff7393f8" />
        <classShapeMoniker Id="516b8633-e8ba-43f7-bf23-8c18e055e9b4" />
      </nodes>
    </associationConnector>
    <classShape Id="f479daef-94e3-451a-b060-f4644304ec8c" absoluteBounds="0.5, 0.5, 2, 2.4109318033854166">
      <DataClassMoniker Name="/DB/MEDICOEXTERNO" />
      <nestedChildShapes>
        <elementListCompartment Id="964d649c-c39e-48c6-b130-215c40080462" absoluteBounds="0.515, 0.96, 1.9700000000000002, 1.8509318033854165" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(2.0625 : 2.91093180338542); (2.0625 : 5)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/MEDICOEXTERNO/MEDICOEXTERNO_ATENCION" />
      <nodes>
        <classShapeMoniker Id="f479daef-94e3-451a-b060-f4644304ec8c" />
        <classShapeMoniker Id="516b8633-e8ba-43f7-bf23-8c18e055e9b4" />
      </nodes>
    </associationConnector>
    <classShape Id="5ce0ebb2-391e-46de-b85c-c6a50434ea12" absoluteBounds="3.125, 0.5, 2, 1.26050048828125">
      <DataClassMoniker Name="/DB/FIRMA" />
      <nestedChildShapes>
        <elementListCompartment Id="a21918ee-6f48-470d-9f0e-a9160faab27e" absoluteBounds="3.1399999999999997, 0.96, 1.9700000000000002, 0.70050048828125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <classShape Id="8080f6a7-cd0f-4e38-a667-8aa34c40969e" absoluteBounds="5.375, 9, 2, 1.9178898111979166">
      <DataClassMoniker Name="/DB/PLANTILLA" />
      <nestedChildShapes>
        <elementListCompartment Id="b6606488-da97-4a5c-9204-1c1874f1fb29" absoluteBounds="5.39, 9.46, 1.9700000000000002, 1.3578898111979165" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <classShape Id="2ecb0a31-9312-4243-9d5a-dcecc886146c" absoluteBounds="1.375, 8.875, 2, 1.75354248046875">
      <DataClassMoniker Name="/DB/EQUIPO" />
      <nestedChildShapes>
        <elementListCompartment Id="b72b559d-fea0-4615-a2ac-08b4dc715230" absoluteBounds="1.3900000000000001, 9.335, 1.9700000000000002, 1.19354248046875" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(3.375 : 8.90625); (4.07291666666667 : 8.90625 : JumpStart); (4.23958333333333 : 8.90625 : JumpEnd); (7.59375 : 8.90625); (7.59375 : 4.48266845703125)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/EQUIPO/EQUIPO_EXAMENXATENCION" />
      <nodes>
        <classShapeMoniker Id="2ecb0a31-9312-4243-9d5a-dcecc886146c" />
        <classShapeMoniker Id="578a0699-bcf4-45c5-9bec-2beb667a6a06" />
      </nodes>
    </associationConnector>
    <classShape Id="8a332fc0-58f9-4d58-ae99-d84b9ef09d01" absoluteBounds="9.375, 10.5, 2, 3.23266845703125">
      <DataClassMoniker Name="/DB/INFORMEMEDICO" />
      <nestedChildShapes>
        <elementListCompartment Id="2696f44c-b32e-4a93-b012-c19292012a86" absoluteBounds="9.39, 10.96, 1.9700000000000002, 2.67266845703125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(9.625 : 8.20027913411458); (9.625 : 10.5)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/PACIENTE/PACIENTE_INFORMEMEDICO" />
      <nodes>
        <classShapeMoniker Id="e4ab888d-5eb4-4b81-a562-baa1ff7393f8" />
        <classShapeMoniker Id="8a332fc0-58f9-4d58-ae99-d84b9ef09d01" />
      </nodes>
    </associationConnector>
    <associationConnector edgePoints="[(4.15625 : 4.29984781901042); (4.15625 : 12.3565291341146); (9.375 : 12.3565291341146)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/ESTUDIO/ESTUDIO_INFORMEMEDICO" />
      <nodes>
        <classShapeMoniker Id="1f3a6a96-bcc1-41c3-8d57-b9987a3cdec1" />
        <classShapeMoniker Id="8a332fc0-58f9-4d58-ae99-d84b9ef09d01" />
      </nodes>
    </associationConnector>
  </nestedChildShapes>
</ordesignerObjectsDiagram>

XML : oh ooh :)

<?xml version="1.0" encoding="utf-8"?>
<Database Name="DATABASEGENERAL" EntityNamespace="Demo.View.Data" ContextNamespace="Demo.View" Class="DB" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
  <Connection Mode="AppSettings" ConnectionString="Data Source=192.168.0.3;Initial Catalog=DATABASEGENERAL;Integrated Security=True" SettingsObjectName="SRIMedico.Properties.Settings" SettingsPropertyName="DATABASEGENERALConnectionString1" Provider="System.Data.SqlClient" />
  <Table Name="dbo.EXAMENXATENCION" Member="EXAMENXATENCIONs">
    <Type Name="EXAMENXATENCION">
      <Column Name="codigo" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
      <Column Name="numeroatencion" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigopaciente" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="numerocita" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigocompaniaseguro" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="ruc" Type="System.String" DbType="Char(11) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoequipo" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="horaatencion" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="codigoestudio" Type="System.String" DbType="Char(12) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoclase" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigomodalidad" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigounidad" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="estadoestudio" Type="System.Char" DbType="Char(1) NOT NULL" CanBeNull="false" />
      <Column Name="prioridad" Type="System.String" DbType="VarChar(20) NOT NULL" CanBeNull="false" />
      <Column Name="turnomedico" Type="System.String" DbType="Char(5)" CanBeNull="true" />
      <Association Name="ATENCION_EXAMENXATENCION" Member="ATENCION" ThisKey="numeroatencion,codigopaciente,codigomodalidad,codigounidad,codigocompaniaseguro,ruc,numerocita" OtherKey="numeroatencion,codigopaciente,codigomodalidad,codigounidad,codigocompaniaseguro,ruc,numerocita" Type="ATENCION" IsForeignKey="true" />
      <Association Name="EQUIPO_EXAMENXATENCION" Member="EQUIPO" ThisKey="codigoequipo" OtherKey="codigoequipo" Type="EQUIPO" IsForeignKey="true" />
      <Association Name="ESTUDIO_EXAMENXATENCION" Member="ESTUDIO" ThisKey="codigoestudio,codigoclase" OtherKey="codigoestudio,codigoclase" Type="ESTUDIO" IsForeignKey="true" />
    </Type>
  </Table>
  <Table Name="dbo.ATENCION" Member="ATENCIONs">
    <Type Name="ATENCION">
      <Column Name="fechayhora" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="numeroatencion" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
      <Column Name="codigopaciente" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="cmp" Type="System.String" DbType="Char(6) NOT NULL" CanBeNull="false" />
      <Column Name="codigocompaniaseguro" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="ruc" Type="System.String" DbType="Char(11) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="numerocita" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigomodalidad" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigounidad" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="peso" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
      <Column Name="talla" Type="System.Single" DbType="Real NOT NULL" CanBeNull="false" />
      <Column Name="edad" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
      <Column Name="codigousuario" Type="System.String" DbType="VarChar(20) NOT NULL" CanBeNull="false" />
      <Association Name="ATENCION_EXAMENXATENCION" Member="EXAMENXATENCIONs" ThisKey="numeroatencion,codigopaciente,codigomodalidad,codigounidad,codigocompaniaseguro,ruc,numerocita" OtherKey="numeroatencion,codigopaciente,codigomodalidad,codigounidad,codigocompaniaseguro,ruc,numerocita" Type="EXAMENXATENCION" />
      <Association Name="PACIENTE_ATENCION" Member="PACIENTE" ThisKey="codigopaciente" OtherKey="codigopaciente" Type="PACIENTE" IsForeignKey="true" />
      <Association Name="MEDICOEXTERNO_ATENCION" Member="MEDICOEXTERNO" ThisKey="cmp" OtherKey="cmp" Type="MEDICOEXTERNO" IsForeignKey="true" />
    </Type>
  </Table>
  <Table Name="dbo.INFORMEMEDICO" Member="INFORMEMEDICOs">
    <Type Name="INFORMEMEDICO">
      <Column Name="numeroinforme" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoestudio" Type="System.String" DbType="Char(12) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="turnosocio" Type="System.String" DbType="Char(5) NOT NULL" CanBeNull="false" />
      <Column Name="fechainforme" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="horainforme" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="tecnica" Type="System.String" DbType="VarChar(3000) NOT NULL" CanBeNull="false" />
      <Column Name="hallazgo" Type="System.String" DbType="VarChar(5000) NOT NULL" CanBeNull="false" />
      <Column Name="conclusion" Type="System.String" DbType="VarChar(3000) NOT NULL" CanBeNull="false" />
      <Column Name="impreso" Type="System.Boolean" DbType="Bit NOT NULL" CanBeNull="false" />
      <Column Name="codigoclase" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigopaciente" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="medicoinforma" Type="System.String" DbType="Char(5) NOT NULL" CanBeNull="false" />
      <Column Name="firmados" Type="System.Data.Linq.Binary" DbType="Image" CanBeNull="true" UpdateCheck="Never" />
      <Column Name="firmauno" Type="System.Data.Linq.Binary" DbType="Image" CanBeNull="true" UpdateCheck="Never" />
      <Column Name="nombreinforme" Type="System.String" DbType="VarChar(150) NOT NULL" CanBeNull="false" />
      <Association Name="ESTUDIO_INFORMEMEDICO" Member="ESTUDIO" ThisKey="codigoestudio,codigoclase" OtherKey="codigoestudio,codigoclase" Type="ESTUDIO" IsForeignKey="true" />
      <Association Name="PACIENTE_INFORMEMEDICO" Member="PACIENTE" ThisKey="codigopaciente" OtherKey="codigopaciente" Type="PACIENTE" IsForeignKey="true" />
    </Type>
  </Table>
  <Table Name="dbo.EQUIPO" Member="EQUIPOs">
    <Type Name="EQUIPO">
      <Column Name="fechaadquirio" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="intensidad" Type="System.Single" DbType="Real NOT NULL" CanBeNull="false" />
      <Column Name="modelo" Type="System.String" DbType="VarChar(40)" CanBeNull="true" />
      <Column Name="marca" Type="System.String" DbType="VarChar(40) NOT NULL" CanBeNull="false" />
      <Column Name="nombreequipo" Type="System.String" DbType="VarChar(35) NOT NULL" CanBeNull="false" />
      <Column Name="codigoequipo" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Association Name="EQUIPO_EXAMENXATENCION" Member="EXAMENXATENCIONs" ThisKey="codigoequipo" OtherKey="codigoequipo" Type="EXAMENXATENCION" />
    </Type>
  </Table>
  <Table Name="dbo.ESTUDIO" Member="ESTUDIOs">
    <Type Name="ESTUDIO">
      <Column Name="nombreestudio" Type="System.String" DbType="VarChar(100) NOT NULL" CanBeNull="false" />
      <Column Name="codigoestudio" Type="System.String" DbType="Char(12) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoclase" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="indicacion" Type="System.String" DbType="VarChar(500)" CanBeNull="true" />
      <Association Name="ESTUDIO_EXAMENXATENCION" Member="EXAMENXATENCIONs" ThisKey="codigoestudio,codigoclase" OtherKey="codigoestudio,codigoclase" Type="EXAMENXATENCION" />
      <Association Name="ESTUDIO_INFORMEMEDICO" Member="INFORMEMEDICOs" ThisKey="codigoestudio,codigoclase" OtherKey="codigoestudio,codigoclase" Type="INFORMEMEDICO" />
    </Type>
  </Table>
  <Table Name="dbo.PACIENTE" Member="PACIENTEs">
    <Type Name="PACIENTE">
      <Column Name="nacionalidad" Type="System.String" DbType="VarChar(20) NOT NULL" CanBeNull="false" />
      <Column Name="direccion" Type="System.String" DbType="VarChar(80)" CanBeNull="true" />
      <Column Name="email" Type="System.String" DbType="VarChar(60)" CanBeNull="true" />
      <Column Name="celular" Type="System.String" DbType="VarChar(20)" CanBeNull="true" />
      <Column Name="telefono" Type="System.String" DbType="VarChar(20) NOT NULL" CanBeNull="false" />
      <Column Name="fechanace" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="sexo" Type="System.Char" DbType="Char(1) NOT NULL" CanBeNull="false" />
      <Column Name="nombres" Type="System.String" DbType="VarChar(35) NOT NULL" CanBeNull="false" />
      <Column Name="apellidos" Type="System.String" DbType="VarChar(45) NOT NULL" CanBeNull="false" />
      <Column Name="dni" Type="System.String" DbType="VarChar(20)" CanBeNull="true" />
      <Column Name="codigopaciente" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Association Name="PACIENTE_ATENCION" Member="ATENCIONs" ThisKey="codigopaciente" OtherKey="codigopaciente" Type="ATENCION" />
      <Association Name="PACIENTE_INFORMEMEDICO" Member="INFORMEMEDICOs" ThisKey="codigopaciente" OtherKey="codigopaciente" Type="INFORMEMEDICO" />
    </Type>
  </Table>
  <Table Name="dbo.MEDICOEXTERNO" Member="MEDICOEXTERNOs">
    <Type Name="MEDICOEXTERNO">
      <Column Name="cmp" Type="System.String" DbType="Char(6) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="apellidos" Type="System.String" DbType="VarChar(45) NOT NULL" CanBeNull="false" />
      <Column Name="nombres" Type="System.String" DbType="VarChar(35) NOT NULL" CanBeNull="false" />
      <Column Name="telefono" Type="System.String" DbType="VarChar(20)" CanBeNull="true" />
      <Column Name="direccion" Type="System.String" DbType="VarChar(80)" CanBeNull="true" />
      <Column Name="email" Type="System.String" DbType="VarChar(60)" CanBeNull="true" />
      <Column Name="fechanacio" Type="System.DateTime" DbType="DateTime" CanBeNull="true" />
      <Column Name="codigoespecialidad" Type="System.Int32" DbType="Int" CanBeNull="true" />
      <Column Name="activo" Type="System.Boolean" DbType="Bit NOT NULL" CanBeNull="false" />
      <Column Name="celular" Type="System.String" DbType="VarChar(20)" CanBeNull="true" />
      <Association Name="MEDICOEXTERNO_ATENCION" Member="ATENCIONs" ThisKey="cmp" OtherKey="cmp" Type="ATENCION" />
    </Type>
  </Table>
  <Table Name="dbo.PLANTILLA" Member="PLANTILLAs">
    <Type Name="PLANTILLA">
      <Column Name="codigoplantilla" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoequipo" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
      <Column Name="codigoestudio" Type="System.String" DbType="Char(12) NOT NULL" CanBeNull="false" />
      <Column Name="tituloplantilla" Type="System.String" DbType="VarChar(150) NOT NULL" CanBeNull="false" />
      <Column Name="tecnica" Type="System.String" DbType="VarChar(3000) NOT NULL" CanBeNull="false" />
      <Column Name="hallazgo" Type="System.String" DbType="VarChar(5000) NOT NULL" CanBeNull="false" />
      <Column Name="conclusion" Type="System.String" DbType="VarChar(3000) NOT NULL" CanBeNull="false" />
    </Type>
  </Table>
  <Table Name="dbo.FIRMA" Member="FIRMAs">
    <Type Name="FIRMA">
      <Column Name="codigofirma" Type="System.String" DbType="VarChar(20) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="siglas" Type="System.String" DbType="Char(5) NOT NULL" CanBeNull="false" />
      <Column Name="imagen" Type="System.Data.Linq.Binary" DbType="Image NOT NULL" CanBeNull="false" UpdateCheck="Never" />
    </Type>
  </Table>
</Database>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一枫情书 2024-07-20 23:18:44

看起来您的数据库架构与您的 DBML 不匹配。 仔细检查您的财产类型和属性是否匹配。

Looks like your database schema doesn't match your DBML. Double check your property types and attributes match.

娇纵 2024-07-20 23:18:44

EXAMENXATENCION 表中的 estadoestudio 字段是 VarChar(1) 吗? 如果是这样,LINQ to SQL 设计器已将其解释为 Char 字段,请在 DBML 设计器或底层 XML 中将列编辑为 System.String 而不是 System.Char。 我还建议您在 LINQ to SQL 中表示的任何其他 VarChar(1) 字段(如果该字段可为空,因为您不能有空字符)使用此方法。

Is the estadoestudio Field from your EXAMENXATENCION Table a VarChar(1) ? if so the LINQ to SQL designer has interpreted this as a Char field, edit your column in your DBML designer or underlying XML to System.String instead of System.Char. I would also recommend this for any other VarChar(1) fields you are representing in LINQ to SQL if the field is nullable as you cannot have a null char.

诠释孤独 2024-07-20 23:18:44

解决方案:

打开一个新项目,添加新的 Linq2SQL 模型,然后复制并粘贴 XML 和 Designer.cs 文件,在此行重命名:

public DB() :
            base(global::SRIMedico.Properties.Settings.Default.DATABASEGENERALConnectionString, mappingSource)
        {
            OnCreated();
        }

其中 SRIMedico 将是您的默认命名空间...
DATABASEGENERALConnectionString 将是您的 ConnectionString 名称..

希望有所帮助

Solution:

Open a new Project, add new Linq2SQL Model and then copy and paste XML and designer.cs file, rename on this line :

public DB() :
            base(global::SRIMedico.Properties.Settings.Default.DATABASEGENERALConnectionString, mappingSource)
        {
            OnCreated();
        }

where SRIMedico will be your Default Namespace...
and DATABASEGENERALConnectionString will be your ConnectionString name..

Hopes help

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文