2017-04-18 59 views
0

它有沒有辦法添加其他測試可以請求:的LINQ to SQL vb.net case語句添加其他測試

Dim exceptBanned = (From c In query _ 
Where Not bannedCCList.Contains(c.Field(Of String)("N°Reçu")) _ 
     Group c By c!code_projet _ 
     Into nb = Count(CInt(c("code_projet"))), ca = Sum(CDec(c("Prix") + CDec(c("tva")))) _ 
     Select nb, ca).ToList 

我想其他測試添加到我的查詢,以下是我已經試過,但遺憾的是它不工作:

If tf = 1 Then 
    exceptBanned = exceptBanned.Where(Function(c) c!type.Equals("Transfert 
    acompte") = False) 
else 
    exceptBanned = exceptBanned.Where(Function(c) c!type.Equals("Transfert 
    acompte") = True) 
end if 

預先感謝

+0

「它不起作用」並不是錯誤或意外結果的正確描述。 –

+0

它給我一個語法錯誤 –

回答

0

我已經解決了我的伊蘇斯,我想與大家分享這一解決方案在這裏:

Dim qryResultsDes = (From order In GlobalDataDesistement.AsEnumerable() _ 
Where order!code_projet = tab.Rows(i).Item("code_projet")) 

    If tf = 1 Then 
    qryResultsDes = qryResultsDes .Where(Function(c) c!type.Equals("Transfert 
    acompte") = False) 
else 
    qryResultsDes = qryResultsDes .Where(Function(c) c!type.Equals("Transfert 
    acompte") = True) 
end if 


Dim exceptBanned = (From c In qryResultsDes _ 
Where Not bannedCCList.Contains(c.Field(Of String)("N°Reçu")) _ 
     Group c By c!code_projet _ 
     Into nb = Count(CInt(c("code_projet"))), ca = Sum(CDec(c("Prix") + CDec(c("tva")))) _ 
     Select nb, ca).ToList