0
我正在調用DataContext對象的ExecuteQuery方法。我期望每行都有一個字符串和一個整數作爲結果,但是當我運行ToList函數時,我所有的值都是無關緊要的。我所有的結果都應該是不同的字符串和數字。如果我直接運行它,我的查詢運行完美,但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
也許給我們展示一些代碼?你如何期望我回答這個? – Pleun
你可以發佈你的代碼嗎? –
感謝您的評論,我已經發布了一個非常簡單的代碼,因爲我的查詢大約有1500個字符。 –