Any ideas how to write this query in LLBLGen?

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 17-Sep-2010 03:53:28   

Hi there,

I'm looking for a predicate expression that updates a row only if the row is referenced by x number of rows.

So something like this...

UPDATE A a SET a.Locked = true WHERE @quantity = (SELECT count(*) FROM B WHERE b.fkey = a.pkey) AND a.pkey = 1;

Any ideas?

Cheers, Ian.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 17-Sep-2010 06:53:35   

You can use ScalarQueryExpression and expressions in your PredicateExpression. See this example (it uses SUM, but you just chance it for COUNT): http://www.llblgening.com/archive/2009/09/llblgen-pro-expressions-and-scalar-queries/

David Elizondo | LLBLGen Support Team