Wrong SQL Creation?

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

Wrong SQL Creation?

Post by Zero-G. » Fri 10 Jun 2011 10:39

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

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Fri 10 Jun 2011 14:00

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.

Post Reply