Referring to Custom Entity Properties in Predicate

Posts   
 
    
wkparry
User
Posts: 4
Joined: 01-Dec-2007
# Posted on: 20-Mar-2008 21:25:58   

Hello,

I tried to search for an answer and wasn't finding it. I apologize if I'm repeating...

I'm using Self-Servicing 2 classes. In my entity class in the custom code section I've added a new property which uses values within the entity as well as information from a related entity to determine whether the entity is "Active" or not. The new property is called "IsProjectActive". The entity is my "ProjectEntity".

In my web-based GUI I have a GridView that displays results of a ProjectCollection which includes the value of IsProjectActive. So far so good the custom property displays fine with the correct results. The purpose of the form is to search for projects. One of the search terms I'd like to use is whether or not the project is active. However, in building the predicate, I don't have the option of ProjectFields.IsProjectActive because it's a custom property.

How can I reference the field IsProjectActive to build a predicate expression and filter results in my GridView so that only Active projects are returned if a user selects to see only active projects?

Thanks for your help!! Warren

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 21-Mar-2008 10:27:15   

You may do in-memory filtering on an entity property using an EntityView. The code should look like the following:

EntityView2<ProjectEntity> activeProjects = new EntityView2<ProjectEntity>(projectsCollection);

PredicateExpression filter = new PredicateExpression();
filter.Add(new EntityProperty("IsProjectActive") == true);
activeProjects.Filter = filter;

Refer to the LLBLGen Pro manual's section "Using the generated code -> Adapter/SelfServicing -> Using the entityViews with entity collections"

wkparry
User
Posts: 4
Joined: 01-Dec-2007
# Posted on: 21-Mar-2008 14:27:16   

Thanks for your help. I'm still relatively new to the product so your response is helpful.