Page 1 of 1

Wrong SQL Creation?

Posted: Fri 10 Jun 2011 10:39
by Zero-G.
Hey

Using your latest components (6.30.165) with VB.NET 2010
I run the following code:

Code: Select all

Artikel = From Query In myDataContext.Artikelstamms Where _
                                   nListInvNr.Contains(Query.Invnr) And _
                                   nListLieferanten.Contains(Query.Lieferant) _
                                   Select Query

Where nListInvNr has a List(Of String) declaration.
When nListInvNr does contain no elements, then the following SQL Code is created:

Code: Select all

SELECT t1.ID, t1.geloescht, t1.InvNr, t1.Lieferant, t1.ArtikelNr, t1.Groesse, t1.Farbe, t1.ArtBez, t1.Mwst, t1.VPreis, t1.DivArt, t1.iCode, t1.oCode, t1.oepreis, t1.EPreis, t1.DatSeit, t1.DatlAenderung, t1.kommisionsware, t1.kommisionswarezurueck, t1.gueltig_von, t1.gueltig_bis, t1.Zeitstempel
FROM artikelstamm t1
WHERE FALSE AND (t1.Lieferant IN (:p0))
The FALSE Statement seems to be something mystique.

THX

Posted: Fri 10 Jun 2011 14:00
by StanislavK
This is the expected behaviour. The "nListInvNr.Contains(Query.Invnr)" expression can be evaluated at the client side (if the nListInvNr list has no elements, this expression is always false), thus the evaluated value is sent instead of translating the whole expression to SQL.