Related tables

Posts   
 
    
Combo
User
Posts: 2
Joined: 13-Apr-2005
# Posted on: 13-Apr-2005 15:49:24   

I'm a newbie to this poweful tool and can't figure out how to get this select query working:

SELECT * FROM Table1 WHERE Table1.ExtrasID Not In (SELECT ExtrasID FROM Table2) And Table1.ModelRangeID = 5

Any hints? Is typed views the way to go? flushed

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 13-Apr-2005 17:10:51   

Combo wrote:

I'm a newbie to this poweful tool and can't figure out how to get this select query working:

SELECT * FROM Table1 WHERE Table1.ExtrasID Not In (SELECT ExtrasID FROM Table2) And Table1.ModelRangeID = 5

Any hints? Is typed views the way to go? flushed

For selfservicing, use:


// Selfservicing:
IPredicateExpression filter = new PredicateExpression();
filter.Add(new FieldCompareSetPredicate(
    EntityFieldFactory.Create(Table1FieldIndex.ExtrasID),
    EntityFieldFactory.Create(Table2FIeldIndex.ExtrasID),
    SetOperator.In, null, true));
filter.AddWithAnd(PredicateFactory.CompareValue(Table1FieldIndex.ModelRangeID, 
    ComparisonOperator.Equal, 5));
Table1Collection results = new Table1Collection();
results.GetMulti(filter);

for Adapter, use:


// Adapter:
IRelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(new FieldCompareSetPredicate(
    EntityFieldFactory.Create(Table1FieldIndex.ExtrasID), null, 
    EntityFieldFactory.Create(Table2FIeldIndex.ExtrasID), null, 
    SetOperator.In, null, true));
filter.PredicateExpression.AddWithAnd(PredicateFactory.CompareValue(Table1FieldIndex.ModelRangeID, 
    ComparisonOperator.Equal, 5));
EntityCollection results = new EntityCollection(new Table1EntityFactory());
DataAccessAdapter adapter = new DataAccessAdapter();
adapter.FetchEntityCollection(results, filter);

That should do it simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Combo
User
Posts: 2
Joined: 13-Apr-2005
# Posted on: 13-Apr-2005 17:16:45   

fantastico amigo smile