2009-02-17 74 views
1

當我嘗試更新時,我得到一個異常,插入作品完美..所以這是: 在System.Data中發生類型'System.InvalidCastException'的第一個機會異常。 Linq.dll 另一個提示...可以先插入一個表中,然後更新另一個表,最後在同一個代碼塊中提交更改()。 我也評論InsertOnSubmit();我和重建的dbml(下降,再創)更名,背景等。 代碼:LINQ to SQL,失敗db.SubmitChanges()

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); 
        } 



       } 

堆棧:

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: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> 
+0

你可以從後DBML生成的XML對於表INFORMEMEDICO? – 2009-02-17 21:27:16

+0

我最近遇到類似的東西。其中一個外鍵不是關聯表中的主鍵嗎? – Kamal 2009-12-18 13:24:21

回答

0

解決方案:

打開一個新的項目,增加新的LINQ2SQL模型,然後複製和粘貼XML和designer.cs文件,重命名這條線:

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

其中SRIMedico將默認命名空間... 和DATABASEGENERALConnectionString將是您的ConnectionString名字..

的希望幫助

0

看起來您的數據庫架構與您的DBML不匹配。仔細檢查你的屬性類型和屬性匹配。

+0

我只是拖放從服務器資源管理器 – 2009-02-17 21:43:03

0

estadoestudio字段從您的EXAMENXATENCION表a VarChar(1)?如果是這樣的話,LINQ to SQL設計者已經將其解釋爲Char字段,請將您的DBML設計器或底層XML中的列編輯爲System.String而不是System.Char。如果字段是空的,因爲你不能有空字符,我也會推薦你在LINQ to SQL中表示的任何其他VarChar(1)字段。