Page 1 of 1

Dynamic Where Clause

Posted: Sat 18 May 2013 14:45
by Zero-G.
Hey
I have an question.
I use a dynamic creation for an advertisment file. So the user can check/uncheck some Options in my Environment and then the query should fire.
This Looks like this:

Code: Select all

Dim myDataContext as New VOptNeu.DataContext
Dim customer = From Query in myDataContext
If checkDateFrom = True Then
    customer = customer.Where(Function (x) x.datefrom >= datefrom.Value
End If
If checkDateUntil = True Then
    customer = customer.Where(Function (x) x.datefrom <= dateuntil.Value
End If
Ok, the mySQL Code, which is created makes 2 subqueries from this, so I get all my customers, because all customers have the date from and the date until.
It Looks, that this Kind of dynamic creation does not Combine the where clauses!? - Am I right? - How could I do it, that the where's are combined?

I know, the correct behaivor would be to use Between, but as you can see, it could be that the checkDateUntil is not checked, so there would be no Kind of between.
Also the Problem Comes, when I make more of this queries.

Hope you understand and know what could help
THX

Re: Dynamic Where Clause

Posted: Tue 21 May 2013 07:54
by MariiaI
We couldn't reproduce this behavior with the latest version of LinqConnect 4.2.247. We are sending you a sample project to the e-mail address you have provided in your forum profile. Please check that the letter is not blocked by your mail filter.
Please make changes to it so that the issue could be reproduced and send it back to us or send us your project.