Problems creating a predicate

Posts   
 
    
Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 14-Sep-2007 00:42:55   

Hi, VB, LLBLGen 2.0, Adapter

This should be simple but I'm all over the place on this. I'm trying to find a PK within a RegionEntity collection which is already bound to a grid, but I can't get past a '_Value of type Boolean cannot be converted to SD.LLBLGEN.Pro.ORMSuppottClasses.IPredicate_' on ent.RegionID = CShort(ID).

        Dim myCollection As EntityCollection(Of RegionEntity)
        myCollection = CType(Me.BindingSource1.DataSource, EntityCollection(Of RegionEntity))

        Dim ent As RegionEntity
        Dim filter As New PredicateExpression()
        filter.Add(ent.RegionID = CShort(ID))
        Dim c As List(Of Integer) = myCollection .FindMatches(filter)

I'm not even sure that I've defined 'ent' correctly. confused

Any ideas anyone?

psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 14-Sep-2007 01:15:03   

You shouldn't need the ent variable at all. I believe you should change:

filter.Add(ent.RegionID = CShort(ID))

To:

RegionFields.RegionID = CShort(ID))

Because of the operator overloading, you may not be able to cast and create the predicate in the same statement. So you may need:

Dim value as short
RegionFields.RegionID = value

(my VB is pretty rusty, so that might not even be close).

HTH,

Phil

Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 14-Sep-2007 03:00:50   

Phil,

That was spot on - couldn't see the wood for the trees.

Many thanks smile