Filtering with aliases

Posts   
 
    
jselesan
User
Posts: 8
Joined: 06-Jun-2012
# Posted on: 20-Aug-2013 20:21:47   

Hi everybody. I'm using LLBL with Self servicing and need to filter a collection with aliases. I have a table named Certification with 2 relations to table Configuration (actually there are more than 2 relations, but for the example, 2 is enough), and Configuration has a relation to Developer. I need to filter by DeveloperId. I know that in SQL I can do something like this:


SELECT * FROM Certification CE 
LEFT JOIN Configuration C1 on C1.Id = CE.TerminalConfgurationId 
INNER JOIN Developer D1 on C1.DeveloperId = D1.Id 
LEFT JOIN Configuration C2 on CE.ControllerConfigurationId = C2.Id 
INNER JOIN Developer D2 on D2.Id = C2.DeveloperId
WHERE D1.Id = @myID OR D2.Id = @myID

Does anybody can help me to create a PredicateExpression to filter my CertificationCollection as I need?

Thanks in advance

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 20-Aug-2013 21:05:55   

When you add these relations, use the RelationCollection.Add() overload that accepts an alias parameter. Then use that same alias on the EntityField used in the PredicateExpression. e.g. CustomerFields.Country.SetObjectAlias("ABC");

jselesan
User
Posts: 8
Joined: 06-Jun-2012
# Posted on: 20-Aug-2013 23:15:33   

Thanks, but I didn't succeed. Could you post an example using my sample model?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Aug-2013 04:32:40   

Please write the code you have tried, so we can figure out why you did not succeed.