Adding parentheses in Where clause

Posts   
 
    
Posts: 19
Joined: 11-Jan-2010
# Posted on: 08-Jul-2010 20:53:45   

Hello everybody,

Could somebody please help me with the following question. How can I add parentheses (round brackets) in my query.

I have defined ResultsetFields, created bkt as IRelationPredicateBucket and defined Relations, then I've added PredicateExpressions:

bkt.PredicateExpression.AddWithAnd(New FieldCompareValuePredicate(PartLocationSettingsFields.ReorderWarningFlag, Nothing, ComparisonOperator.Equal, True))

bkt.PredicateExpression.AddWithAnd(PartInventoryAdjustmentFields.LocationId = PartLocationSettingsFields.LocationId) bkt.PredicateExpression.AddWithOr(New FieldCompareNullPredicate(PartInventoryAdjustmentFields.LocationId, Nothing, False)) bkt.PredicateExpression.AddWithOr(New FieldCompareNullPredicate(PartLocationSettingsFields.LocationId, Nothing, False))

When I run FetchTypedList(flds, dt, bkt, sorter, True, gb) in the query I have ...

WHERE ( ( partlocationsettings.ReorderWarningFlag = @ReorderWarningFlag1 AND partinventoryadjustment.LocationId = partlocationsettings.LocationId OR partinventoryadjustment.LocationId IS NULL OR partlocationsettings.LocationId IS NULL))

How can I make it look like this (I've tried other combinations but they did not work out):

WHERE ( partlocationsettings.ReorderWarningFlag = @ReorderWarningFlag1 AND (partinventoryadjustment.LocationId = partlocationsettings.LocationId OR partinventoryadjustment.LocationId IS NULL OR partlocationsettings.LocationId IS NULL))

Thanks a lot in advance, Galina.

Posts: 19
Joined: 11-Jan-2010
# Posted on: 08-Jul-2010 21:38:18   

Never mind, I got it. :-)