G Perrin
G Perrin

Reputation: 5

how to write a query with 2 equals on linq?

I'm a beginner in VB.NET and recently I tried to write a LinQ query. I would like to use equals twice in my query but it does not work the way I want, I get the following error message:

Expression expected" on the &&

Code:

Dim Que2 = From couple2 In list_couple_C
           Where couple2.colonne1.Equals(My_list(j))
              && couple2.colonne2.Equals(couple1.colonne2)
           Select couple2

Is it possible to use two equals in the same query? And if so, can someone tell me what is wrong in my query?

Upvotes: 0

Views: 80

Answers (1)

Ric
Ric

Reputation: 13248

&& equivalent in VB.NET is AndAlso. & equivalent is just And. See Below:

Dim Que2 = From couple2 In list_couple_C
           Where couple2.colonne1.Equals(My_list(j)) AndAlso 
           couple2.colonne2.Equals(couple1.colonne2)
           Select couple2

Upvotes: 3

Related Questions