Like Operator & equals does not work

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

Like Operator & equals does not work

Post by Zero-G. » Sat 04 Dec 2010 14:04

Hey
Using your latest Components for VB.NET (LinQConnect v6)

When I run the following code:

Code: Select all

 myArtikel = From query In _
                    GetDataContext.Artikelstamms Where _
                    Devart.Data.Linq.SqlMethods.Like(query.Invnr, cmbInvNr.Value) And _
                    query.Lieferant = cmbLieferant.Value And _
                    Devart.Data.Linq.SqlMethods.Like(query.Artikelnr, IIf(txtArtNummer.Text.Length > 0, txtArtNummer.Text, "%")) And _
                    Devart.Data.Linq.SqlMethods.Like(query.Groesse, IIf(txtGroesse.Text.Length > 0, txtGroesse.Text, "%")) And _
                    Devart.Data.Linq.SqlMethods.Like(query.Farbe, IIf(txtFarbe.Text.Length > 0, txtFarbe.Text, "%")) And _
                    Devart.Data.Linq.SqlMethods.Like(query.Artbez, IIf(txtArtBeschreibung.Text.Length > 0, txtArtBeschreibung.Text, "%"))
Then I get the following error: (translated from the german version)
The object of type "Devart.Data.Linq.DataQuery`1[VOPT.VOptNeuContext.Artikelstamm]" can not be cast into Typ "VOPT.VOptNeuContext.Artikelstamm"

query.Lieferant is a Bigint field. - So i can't use the like operator. When I delete the query.Lieferant query, then everything works fine.

THX

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

Post by StanislavK » Mon 06 Dec 2010 18:10

Please check the definition of the MyArtikel variable. Such problem may occur, e.g., if MyArtikel was declared without the type specified (i.e., 'Dim MyArtikel') and was later assigned a value of the VOPT.VOptNeuContext.Artikelstamm type. In this case, MyArtikel is actually a VOptNeuContext.Artikelstamm instance, but is treated as DataQuery, causing a type mismatch.

If this is not the case, please see the test project. I've sent it in a letter, please check that it was not blocked by your mail filter. Please specify what should be changed in the sample to reproduce the problem, or send us your test project.

Post Reply