0

以下のSQLクエリをvb.netのLinqステートメントに変換する方法を教えてください

select   distinct PATIENT_DIAGNOSIS_DESCRIPTION, PATIENT_DIAGNOSIS_CODE,
         PATIENT_DIAGNOSIS_ACCOUNT,PATIENT_DIAGNOSES_STATUS 
from     MF_PATIENT_DIAGNOSES 
where    PATIENT_DIAGNOSIS_ACCOUNT= '31'
AND      UPPER(PATIENT_DIAGNOSES_STATUS) <> 'ENTRY ERROR' 
GROUP BY PATIENT_DIAGNOSIS_DESCRIPTION, PATIENT_DIAGNOSIS_CODE, 
         PATIENT_DIAGNOSIS_ACCOUNT,PATIENT_DIAGNOSES_STATUS 
ORDER BY PATIENT_DIAGNOSIS_DESCRIPTION
4

1 に答える 1

1

私は C# で書いたので、VB に変換することができます。

item.Field から Field のように、列のタイプに応じてフィールド タイプを変更できます。

 var result = (from item in MF_PATIENT_DIAGNOSES.AsEnumerable()
                   where item.Field<int>("PATIENT_DIAGNOSIS_ACCOUNT") == 31 && item.Field<string>("PATIENT_DIAGNOSES_STATUS").ToUpper() != "ENTRY ERROR"
                   orderby item.Field<string>("PATIENT_DIAGNOSIS_DESCRIPTION")
                   select new
                   {
                       PATIENT_DIAGNOSIS_DESCRIPTION = item.Field<string>("PATIENT_DIAGNOSIS_DESCRIPTION"),
                       PATIENT_DIAGNOSIS_CODE = item.Field<string>("PATIENT_DIAGNOSIS_CODE"),
                       PATIENT_DIAGNOSIS_ACCOUNT = item.Field<string>("PATIENT_DIAGNOSIS_ACCOUNT"),
                       PATIENT_DIAGNOSES_STATUS = item.Field<string>("PATIENT_DIAGNOSES_STATUS "),
                   }).Distinct();

このhttp://www.developerfusion.com/tools/convert/csharp-to-vb/コンバーターを使用して変換します

Dim result1 = (From item In MF_PATIENT_DIAGNOSES.AsEnumerable() Where item.Field(Of Integer)("PATIENT_DIAGNOSIS_ACCOUNT") = 31 AndAlso item.Field(Of String)("PATIENT_DIAGNOSES_STATUS").ToUpper() <> "ENTRY ERROR"Order By item.Field(Of String)("PATIENT_DIAGNOSIS_DESCRIPTION")New With { _
Key .PATIENT_DIAGNOSIS_DESCRIPTION = item.Field(Of String)("PATIENT_DIAGNOSIS_DESCRIPTION"), _
Key .PATIENT_DIAGNOSIS_CODE = item.Field(Of String)("PATIENT_DIAGNOSIS_CODE"), _
Key .PATIENT_DIAGNOSIS_ACCOUNT = item.Field(Of String)("PATIENT_DIAGNOSIS_ACCOUNT"), _
Key .PATIENT_DIAGNOSES_STATUS = item.Field(Of String)("PATIENT_DIAGNOSES_STATUS ") 
}).Distinct()
于 2012-09-28T06:04:05.670 に答える