2012-06-22 2 views
0

DataContext 개체의 ExecuteQuery 메서드를 호출하고 있습니다. 결과적으로 각 행에 대해 String과 Integer가 필요하지만 ToList 함수를 실행할 때 모든 값은 0이고 0입니다. 내 결과는 문자열과 숫자가 달라야합니다. 직접 실행하면 쿼리가 완벽하게 실행되지만 ExecuteQuery는 유효한 결과 대신 가비지를 반환합니다. 이것의 원인이 무엇일까요?ASP.NET DataContext 문제

미리 감사드립니다.

편집 :

public function something as List(of Pair(of String, Integer)) 
      Dim c As TTDataContext = ContextFactory.CreateDataContext() 
      Dim startValueLen = CStr(StartValue).Length 
      Dim query As String = "select top " & CStr(Limit) & " case " & 
                    " when WONum like '0000%' then SUBSTRING(WONum, 5, Len(WONum) - 4) " & 
                    " when WONum like '000%' then SUBSTRING(WONum, 4, Len(WONum) - 3) " & 
                    " when WONum like '00%' then SUBSTRING(WONum, 3, Len(WONum) - 2) " & 
                    " when WONum like '0%' then SUBSTRING(WONum, 2, Len(WONum) - 1) " & 
                    " else WONum " & 
                    " end as retVal, " & 
                    " case " & 
                    " when WONum like '0000%' then 1 " & 
                    " when WONum like '000%' then 2 " & 
                    " when WONum like '00%' then 3 " & 
                    " when WONum like '0%' then 4 " & 
                    " else LEN(WONum) " & 
                    " end as retLen " & 
                    " from TblWorkOrder " & 
                    " where CompanyID = " & CStr(CompanyID) & " and LEN(WONum) >= " & CStr(startValueLen) & " and (WONum > '" & CStr(StartValue) & "' or LEN(WONum) > " & CStr(startValueLen) & ") " & 
                    " order by retLen, retVal" 
      Dim temp = c.ExecuteQuery(Of Pair(Of String, Integer))(query) 
      Return temp.ToList 
End Function 
+2

아마도 코드를 보여줄 수 있습니까? 어떻게 내가 이걸 대답하리라고 기대하니 ??? – Pleun

+0

코드를 게시 할 수 있습니까? –

+0

귀하의 의견을 주셔서 감사합니다, 내 질문은 약 1500 문자 때문에 postet 아주 간단한 코드를했습니다. –

답변

0

문제의 원인은 내 쌍 클래스는 제 1 및 제 2 속성을 가지고 내가 첫 번째로하고 두 번째로 내 결과를 반환하지 않은 것이 었습니다. 그래서 문제의 해결책은 첫 번째 값을 First로, 두 번째 값을 retVal 및 retLen 대신 Second로 반환하는 것입니다.