Converting Query to LLBLGen

Posts   
 
    
pandu avatar
pandu
User
Posts: 86
Joined: 18-May-2006
# Posted on: 17-Jan-2008 15:57:55   

Hi:

How do I convert this query to LLBLGen:

select * from qheader where status=2 and qnumber in (select qnumber from qsupplier where supplierid= 'ABC' ) and qnumber not in (select qnumber from qbid where supplierid= 'ABC' )

The problem is one query using IN and another one is using NOT IN.

Any help is appreciated.

Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 18-Jan-2008 08:38:45   

Use 2 insatances of FieldCompareSetPredicate, and specify true for the negate parameter for the NOT IN one.

pandu avatar
pandu
User
Posts: 86
Joined: 18-May-2006
# Posted on: 18-Jan-2008 09:03:20   

We use FieldCompareRangePredicate and here is the code:

Dim values1 As New ArrayList()
Dim i As Integer
For i = 0 To 10
     values1.Add(i)
Next
Dim bucketRelation As IRelationPredicateBucket = New RelationPredicateBucket()
bucketRelation.PredicateExpression.AddWithAnd(New FieldCompareRangePredicate(qheaderFields.qnumber, False, values1))

In the last line of this code we get the error as following


Overload resolution failed because no accessible 'New' can be called without a narrowing conversion:

    'Public Sub New(field As SD.LLBLGen.Pro.ORMSupportClasses.IEntityField, negate As Boolean, ParamArray values() As Object)': Argument matching parameter 'field' narrows from 'SD.LLBLGen.Pro.ORMSupportClasses.EntityField2' to 'SD.LLBLGen.Pro.ORMSupportClasses.IEntityField'.

    'Public Sub New(field As SD.LLBLGen.Pro.ORMSupportClasses.IEntityField, objectAlias As String, ParamArray values() As Object)': Argument matching parameter 'field' narrows from 'SD.LLBLGen.Pro.ORMSupportClasses.EntityField2' to 'SD.LLBLGen.Pro.ORMSupportClasses.IEntityField'.

    'Public Sub New(field As SD.LLBLGen.Pro.ORMSupportClasses.IEntityField, objectAlias As String, ParamArray values() As Object)': Argument matching parameter 'objectAlias' narrows from 'Boolean' to 'String'.

    'Public Sub New(field As SD.LLBLGen.Pro.ORMSupportClasses.IEntityField, ParamArray values() As Object)': Argument matching parameter 'field' narrows from 'SD.LLBLGen.Pro.ORMSupportClasses.EntityField2' to 'SD.LLBLGen.Pro.ORMSupportClasses.IEntityField'.   

We have similar error when we use FieldCompareSetPredicate.

If we set negate to the bucketrelation as a second step like bucketRelation.negat=true, it works but it applies the negate to both conditions.

What am I missing?

I am running with LLBLGen 2.0 with Adapter.

Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 18-Jan-2008 09:24:30   

Please check the LLBLGen Pro Reference manual, for all possible overloads of the CTors of these predicates, as you are using the SelfServicing overloads rather than the Adapter ones. For example your code should have been:

Dim values1 As New ArrayList() Dim i As Integer For i = 0 To 10 values1.Add(i) Next Dim bucketRelation As IRelationPredicateBucket = New RelationPredicateBucket() bucketRelation.PredicateExpression.AddWithAnd(New FieldCompareRangePredicate(qheaderFields.qnumber, Nothing, False, values1))

pandu avatar
pandu
User
Posts: 86
Joined: 18-May-2006
# Posted on: 19-Jan-2008 08:15:12   

It worked great.

Thanks Walaa. smile