simple filter?

Posts   
 
    
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 27-Feb-2006 21:37:35   

version 1.0.2005.1 final (self-servicing) VS2005 winforms


hiya,

I have a simple filter question. I want to filter an entityCollection.


private myProject.CollectionClasses.TblDeliveryProductsCollection currDeliveries;

there is a field in the entity named "deliveryId"

I think that I should be using a predicate to filter? All I want to do is the equivalent of:

WHERE deliveryId = 1 etc

I know it's a simple question, but can anyone help me out?

many thanks,

yogi

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 27-Feb-2006 22:03:14   

Yogi It would be something like this

IPredicateExpression filter = new PredicateExpression();
filter.Add(PredicateFactory.CompareValue(YourEntityFieldIndex.Field, ComparisonOperator.Equal, 1));

This is a direct copy from the manual 'best practices-->How do I' . I recomment that you have a quick look at it.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39930
Joined: 17-Aug-2003
# Posted on: 27-Feb-2006 23:10:41   

You mean in-memory filtering?

Frans Bouma | Lead developer LLBLGen Pro
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 28-Feb-2006 20:03:54   

hiya,

yes, a simple in-memory filter. I am able to create the filter, according to the manual best practices.

However, for the life of me, I can't figure out how to APPLY this filter to the entityCollection.

Can anyone help?

cheers,

yogi

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39930
Joined: 17-Aug-2003
# Posted on: 28-Feb-2006 20:31:49   

yogiberr wrote:

hiya,

yes, a simple in-memory filter. I am able to create the filter, according to the manual best practices.

However, for the life of me, I can't figure out how to APPLY this filter to the entityCollection.

Can anyone help?

In-memory filtering isn't build in yet, that comes in v2. The only option you have now is to manually traverse the collection and collect the ones which match.

Frans Bouma | Lead developer LLBLGen Pro
JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 01-Mar-2006 03:11:27   

Thinking outside the LLBLGen box for a moment, have you considered using the Filter property of a BindingSource (2005) or DataView (2003) object?

It would be a REALLY simple in memory filter and not provide the same support as the LLBL typed code, but may meet your needs.

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 02-Mar-2006 15:46:46   

hiya,

Well, I'll be doing some more complex stuff with the collection later, so i want to stick with an entityCollection.

it seems that the code below successfully filter the entityCollection:


 IPredicateExpression filter = new PredicateExpression();
            filter.Add(PredicateFactory.CompareValue(TblDeliveryProductsFieldIndex.DeliveryId, ComparisonOperator.Equal, 0));

currDeliveries.GetMulti(filter);


I'm not sure why it was mentioned that I'd manually have to iterate thru the rowsconfused

This seems to work fine.

many thanks,

yogi

BertS
User
Posts: 89
Joined: 28-Jul-2005
# Posted on: 03-Mar-2006 13:17:21   

yogiberr wrote:

I'm not sure why it was mentioned that I'd manually have to iterate thru the rowsconfused

Because this code does a refetch, and so isn't the same as in memory filtering simple_smile