Joins, Need Help

Posts   
 
    
Insane
User
Posts: 10
Joined: 19-Sep-2006
# Posted on: 05-Oct-2006 13:00:14   

Hi, I want to join 2 tables like this;

SELECT FRM.* FROM dbo.BOS_Form AS FRM WHERE FRM.FormID NOT IN (SELECT FormID FROM BOS_FormSecurity WHERE SecurityGroupID = 2)

I'm using SelfServicing classes and newbie with the concept. I saw not in filters but couldn't be able to run it. I tried to make it with prefetch but it returned an error that says the field not belongs to BOSForm entity. I want to return IList or DataTable or a projection.

Could you please show me a sample code for this?

I am using LLBLGen Pro V2.0 with .NET Framework 2.0

Insane
User
Posts: 10
Joined: 19-Sep-2006
# Posted on: 05-Oct-2006 14:03:05   

I have solved it this way but didn't like to fill the arraylist... There must be a better way to do this. Can you suggest anything?

BosFormSecurityCollection formSec = new BosFormSecurityCollection();

IPredicateExpression filter = new PredicateExpression(BosFormSecurityFields.SecurityGroupId == 2); formSec.GetMulti(filter);

ArrayList keys = new ArrayList(); for (int i = 0; i < formSec.DefaultView.Count; i++) { keys.Add(formSec.DefaultView[i].FormId); }

BosFormCollection forms = new BosFormCollection(); IPredicateExpression subFilter = new PredicateExpression(); subFilter.Add(new FieldCompareRangePredicate(BosFormFields.FormId, keys)); subFilter.Negate = true;

forms.GetMulti(subFilter);

dataGridView1.DataSource = forms.GetList();

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 05-Oct-2006 16:07:31   

This can be done easily with the FieldCompareSetPredicate

Please consult the LLBLGen Pro manual: "Using the generated code -> SelfServicing -> Filters and sorting -> The predicate system"