trying to retrieve a filtered typed view using predicate :failure

Posts   
 
    
vzwMann
User
Posts: 6
Joined: 28-Mar-2007
# Posted on: 20-Apr-2007 03:15:04   

Using: VS 2005 Llbl Gen Pro V2 SQL 2005 Brain 1972 lol!

Ok, I tried to mimic this example in the help file:

Dim invoices As New InvoicesTypedView() Dim adapter As New DataAccessAdapter() Dim bucket As New RelationPredicateBucket() bucket.PredicateExpression.Add(New FieldCompareValuePredicate(InvoicesFields.OrderId, Nothing, ComparisonOperator.GreaterThan, 11000))

adapter.FetchTypedView(invoices.GetFieldsInfo(), invoices, bucket, True)

But I needed to compare against a an ID --> TaskId, plus the above predicate expression didn't seem to work for me and I ended up using a similar predicate expression pattern I found for LLBL V2: ' [VB.NET] .NET 2.0 Dim A As IPredicateExpression = New PredicateExpression() A.Add(Table1Fields.Foo = "One")

So here is my final code: Dim adptr As New DataAccessAdapter Dim TaskResources As New DL.TypedViewClasses.ResourceDetailsTypedView Dim fltrs As New RelationPredicateBucket Dim fltr As IPredicateExpression = New PredicateExpression() Dim TaskId As Integer

    TaskId = CInt(Me.ResourceTasksList.SelectedValue)
    fltr.Add(ResourceFields.TaskId = TaskId)
    fltrs.PredicateExpression.Add(fltr)
    adptr.FetchTypedView(TaskResources, fltrs, True)
    Me.AssignedResourceList.DataSource = TaskResources
    Me.AssignedResourceList.ValueMember = "Id"
    Me.AssignedResourceList.DisplayMember = "ActualName"

My Error: {"The multi-part identifier "EusProjectPortfolio.dbo.Resource.TaskId" could not be bound."}

Does anyone see my error? I can't seem to figure this one out, I take the filter out and I am good.

Here is my attempt to mirror exactly as the help file shows: fltr.Add(New FieldCompareValuePredicate(ResourceDetailsFields.TaskId, ComparisonOperator.Equal, TaskId))

Which gives me this error: {"Unable to cast object of type 'SD.LLBLGen.Pro.ORMSupportClasses.EntityField2' to type 'SD.LLBLGen.Pro.ORMSupportClasses.IEntityField'."}

Thanks in advance!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 20-Apr-2007 10:05:24   

You should filter in a field in the TypedView/view not on an entity/table. Try the following:

fltr.Add(ResourceDetailsFields.TaskId = TaskId)
vzwMann
User
Posts: 6
Joined: 28-Mar-2007
# Posted on: 20-Apr-2007 18:52:15   

simple_smile simple_smile smile smile smile

Thank you again!

First round fix... I don't know why I wasn't thinking of this. My brain was tired!confused