&& Operator and parentheses

Posts   
 
    
can1
User
Posts: 77
Joined: 16-Sep-2005
# Posted on: 12-Mar-2010 21:00:24   

Hello,

When I use the short-circuited && operator in a LINQ query, LL 2.6, the query output appears to be bracketed in the short-circuited order:


WHERE ( 
( ( ( ( ( ( ( ( ( ( ( ( 
            [LPLA_1].[field1] = 43876) 
            AND ( [LPLA_1].[field1] = 699891)) 
            AND ( [LPLA_1].[field2] = 15640)) 
            AND ( [LPLA_1].[field3] = 1)) 
            AND ( [LPLA_1].[field4] = 3284)) 
            AND ( [LPLA_1].[field5] = 1)) 
            AND ( [LPLA_1].[field6] = 0)) 
            AND ( [LPLA_1].[field7] >= '3/11/2010 12:00:00 AM')) 
            AND ( [LPLA_1].[field8] < '3/12/2010 12:00:00 AM'))))))


Does anyone know if there is:

  1. A SQL Server performance implication of feeding it the WHERE predicates with short-circuited where clauses with all the parentheses?

  2. A way to just list the predicates without the short-circuiting logic (no parentheses), which is how I would normal type the SQL if I was typing the query?

Thanks.

Can1

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-Mar-2010 23:50:20   

The parenthesis wont add overhead in my opinion and if it will I think that is insignificant because sql already parse those kind of things no matter how many parenthesis your query have. The LLBGen API construct queries in the best possible manner, so don't worry about that.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 13-Mar-2010 11:04:57   

The parentheses aren't harmful for performance and they actually make sure your predicate works, as it avoids you making mistakes like adding an AND and OR predicate to the same expression.

Frans Bouma | Lead developer LLBLGen Pro