Linq If statement

Posts   
 
    
MacSimon
User
Posts: 3
Joined: 06-Mar-2009
# Posted on: 02-Apr-2009 15:59:17   

Example, I have a database about vehicles and I want to see the vehicles with the selected horsepower, the selected weight, the selected make,......

but nothing HAS to be selected.

So I would like to add a if statement in my linq query:

if horsepower.isFilledIn then vehicle.horsepower = horsepower and so on

How do I do this without having to make 1000 overloads

thanks.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 02-Apr-2009 20:53:43   

Please have a look at the documentation about predicates

These will allow you to dynamically construct the "where" clause of your filter based on the values that your user has requested to filter on.

Matt

MacSimon
User
Posts: 3
Joined: 06-Mar-2009
# Posted on: 03-Apr-2009 12:32:04   

Yes, thanks for the information, but I was wondering how to do this in LINQ?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 03-Apr-2009 14:38:51   

Take a look at this thread

Matt

TaLz
User
Posts: 12
Joined: 26-May-2009
# Posted on: 26-May-2009 14:57:27   

i have the same problem and the linq to the thread u put on your last post does not work. could u put a new link or answer. thanks in advance. TaLZ

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 26-May-2009 17:33:10   

TaLz wrote:

i have the same problem and the linq to the thread u put on your last post does not work. could u put a new link or answer. thanks in advance. TaLZ

Please start a **new **thread and explain your own problem in detail. 'the same problem' isn't useful, even though it looks like the same problem: you should provide the information as described in this thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=12769

Frans Bouma | Lead developer LLBLGen Pro