Dynamic Where Clause

Dynamic Where Clause

Postby Zero-G. » Sat 18 May 2013 14:45

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
Zero-G.
 
Posts: 390
Joined: Sat 09 Dec 2006 12:20

Re: Dynamic Where Clause

Postby MariiaI » Tue 21 May 2013 07:54

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.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17


Return to LinqConnect (LINQ to SQL support)