VB linq to entity Поле с именем FIELD_NAME не существует - PullRequest
0 голосов
/ 20 октября 2018

Последние часы я пытался выяснить, что является причиной этого исключения: поле с именем GENDER_DESC не существует.Вот мои коды:

Public Class RelationPatient
    Public PatNetId As String
    Public PatNetIdRel As String
    Public Nom As String
    Public Prenom As String
    Public Sexe As String
    Public TypeRel As String
    Public Ordre As String
    Public DateEnrol As Date
End Class

Public Shared Function GetRelPatient(ByVal PatNetId As String) As List(Of RelationPatient)
        Using context As New DAL.SanteReprodEntities
            context.Database.Connection.Open()
            Dim patient As List(Of RelationPatient)
            patient = (From p In context.PAT_REL
                       Join pa In context.PATIENTS.Include("GENDER_REF") On p.PAT_NET_ID_REL Equals (pa.PAT_NET_ID)
                       Join pn In context.PAT_NAME On pn.PAT_NET_ID Equals (p.PAT_NET_ID_REL)
                       Where p.PAT_NET_ID = PatNetId _
                       And p.VOIDED = 2 Select New RelationPatient With {.PatNetId = p.PAT_NET_ID, .PatNetIdRel = p.PAT_NET_ID_REL, .Nom = pn.LASTNAME, .Prenom = pn.FIRSTNAME, .Sexe = pa.GENDER_REF.GENDER_DESC, .TypeRel = p.REL_TYPE_ID, .Ordre = p.PATIENT_INDEX_TEMOIN, .DateEnrol = pa.ENROL_DATE}).ToList
            Return patient
            context.Database.Connection.Close()
        End Using
    End Function

Private Sub FrmLienPatient_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
        DsEnrolement.PAT_REL.Clear()
        DsEnrolement.Merge(DAL.dalManager.GetPatRelation(PAT_NET_ID))
        Dim patRel As List(Of DAL.RelationPatient)
        Dim sexe As String = String.Empty

        patRel = DAL.dalManager.GetRelPatient(PAT_NET_ID)
        If patRel IsNot Nothing Then
            If patRel.Count > 0 Then
                For Each rel As DAL.RelationPatient In patRel
                    MsgBox(rel.PatNetIdRel + ", " + rel.Nom + ", " + rel.Prenom + ", " + rel.Sexe + ", " + rel.TypeRel + ", " + rel.Ordre + ", " + rel.DateEnrol.ToShortDateString) 'This message is displayed well
                    PATI_RELDataGridView.Rows.Add(New String() {rel.PatNetIdRel, rel.Nom, rel.Prenom, sexe, rel.TypeRel, rel.Ordre, rel.DateEnrol.ToShortDateString}) 'Even if I put any string there like PATI_RELDataGridView.Rows.Add(New String() {"", "", "", "", "", "", ""}) the result is the same
                Next
            End If
        End If
    End Sub

Заранее спасибо за помощь.

...