TypedLists and Predicates

Posts   
 
    
AlanD
User
Posts: 26
Joined: 19-Sep-2006
# Posted on: 16-Oct-2006 17:36:31   

Hi All, I'm getting a compile error I don't understand trying to create a predicate filter for a TypedList.

The codeline is this: IPredicateExpression permFilter = new PredicateExpression(PredicateFactory.CompareValue(PermissionTypedListFieldIndex.PersonId, ComparisonOperator.Equal, User.PersonId));

and the error is this: cannot convert from '<snip>.PermissionTypedListFieldIndex' to '<snip>.ActivityFieldIndex'

It obviously doesn't like PermissionTypedListFieldIndex as one of the Comparison fields, but I don't know why. It seems to want an EntityFieldIndex rather than a TypedListFieldIndex. Can I not use a Predicate with Typed Lists or am I going about filtering a TypedList the wrong way?

Thanks in advance Alan

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 16-Oct-2006 17:58:32   

Hi,

having looked at the predicatefactory template, it indeed does not include the typedlists. You may add that manually if you wish.

Otherwise, you can go for the entityfield your typedlistfield is mapped on. That should work.

Still, keep in mind that the new operator overloads have made the factories less useful, and their not included in the main scenarios anymore by default.

AlanD
User
Posts: 26
Joined: 19-Sep-2006
# Posted on: 17-Oct-2006 10:23:19   

Hi Jesse, Thanks for that, but I'm none the wiser I know a good joke along these lines, but I won't bore you!

I want to work with a typed list rather than an entity.

The example in the manual uses TableFields. Should I be trying to work with fields from the datatable underlying the typedlist?

Can you give me an example line of code to generate a predicate that will filter based on the value of a typedlist field?

Thanks, Alan

Rogelio
User
Posts: 221
Joined: 29-Mar-2005
# Posted on: 17-Oct-2006 13:21:33   

AlanD wrote:

The example in the manual uses TableFields. Should I be trying to work with fields from the datatable underlying the typedlist?

Alan,

As far as I know the way to create predicate for typedlist is using the fieldsindex from the entities underlying the typedlist, this give you more freedom to create predicate because you can create predicate based in fields that are not part of the typedlist. The only time that I used the typedlist fieldsindex was to get the field from the typedlist and changed its aggregate function property before fetching it.

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 17-Oct-2006 15:20:29   

Hi,

as Rogelio stated, I'm not suggesting to switch to use entities, but rather to define your typedlist predicates with the entity fields it's is mapped from.

Have a look in the manual for "Generated code - Using the typed list classes". You'll find the code sample you're asking for.

Cheers

AlanD
User
Posts: 26
Joined: 19-Sep-2006
# Posted on: 17-Oct-2006 17:12:41   

Ah yes, that's much better. Thanks for your help Rogelio and Jesse

Alan

M6rk
User
Posts: 37
Joined: 29-Sep-2004
# Posted on: 06-Apr-2007 22:44:25   

I have a typed view based on a view that has a contrived field.

The view is made up of something like: Create View V AS SELECT 1 AS Reserved, Name FROM X UNION SELECT 0 AS Reserved, Name FROM Y

The field "Reserved" does not exist in the base entity. Any way i can filter out based on Reserved field?

(Using version 2 self servicing)

Thank you! Mark

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 08-Apr-2007 19:29:27   

(please, next time start a new thread, your question has nothing to do with this original thread!)

Your typed view should have a Reserved field, does it not? If it does, you could filter on it, using the typedview's fields. Could you check if the typed view has that field?

Frans Bouma | Lead developer LLBLGen Pro
M6rk
User
Posts: 37
Joined: 29-Sep-2004
# Posted on: 09-Apr-2007 22:40:44   

Otis wrote:

(please, next time start a new thread, your question has nothing to do with this original thread!)

Your typed view should have a Reserved field, does it not? If it does, you could filter on it, using the typedview's fields. Could you check if the typed view has that field?

I am sorry about posting against the wrong thread. I will try not make that mistake again! flushed

My typed view's typed datarow has a "Reserved" field. My TypedView class does expose "Reserved" property. I just had to find it simple_smile in the HelperClass area...

All set now. Thank you!