Question about the dynamic lists example in the documentation

Posts   
 
    
younghov
User
Posts: 8
Joined: 14-Nov-2006
# Posted on: 17-Dec-2006 19:51:57   

Hi,

In the "Creating Dynamic Lists" section of the Help Docs, there's an example that returns a result set of Managers and how many Employess they manage. Supose, I wanted to add a filter on Employees so that, for example, I want the result to only count employess who's last names are "Smith".

How would I do that?

I have a similar query but just can't figure out the right way to add the filter. I'm using self servicing by the way.

Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 18-Dec-2006 07:53:19   

I assume you want the following query:


SELECT M.FirstName, M.LastName, Count(E.LastName) 
FROM Employee M
INNER JOIN Employee E 
ON M.EmployeeId = E.ManagerId
AND E.LastName = 'Smith'

And for this you should set the CustomFilter of the EntityRelation used:


IEntityRelation relation = EmployeeEntity.Relations.EmployeeEntityUsingEmployeeId;
relation.CustomFilter = new PredicateExpression(new FieldCompareValuePredicate(EmployeeFields.LastName, ComparisonOperator.Equal, "Smith", "Employee"));
IRelationCollection relations = new RelationCollection();
relations.Add(relation, "Employee", "Manager", JoinHint.None);

If the query I assumed is not what you want, please supply your query.