query with join...between...and in llblgen

Posts   
 
    
bunzee
User
Posts: 84
Joined: 20-Mar-2007
# Posted on: 22-Mar-2008 00:46:09   

dotnet 2.0 llblgen 2.0.0.0 Final

Here are my tables relationships:


Domain.Code 1:n Line.Domain_Code
Domain.Code 1:n Code_Type.Domain_Code_Range_Start
Domain.Code 1:n Code_Type.Domain_Code_Range_End

Here's my sql statement:


select Line.id, Code_Type.id from Line
join Code_Type on Line.Domain_Code between Code_Type.Domain_Code_Range_Start and Code_Type.Domain_Code_Range_End

QUESTION: How can I write an relationship in LLBLGEN that is equivalent to the "join...between...and" sql statement above?

Thanks,

BZ

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 22-Mar-2008 05:00:18   

You should use Custom filter (Ref: LLBLGenPro Help - Using the generated code - (Adapter or SelfServicing) - Filtering and sorting - Advance filtering usage - Custom filters for entity relations).

You could fetch the results in a EntityCollection or a DynamicList. The relation part in both cases should look like:

IRelationPredicateBucket bucket = new RelationPredicateBucket();

IEntityRelation relationToAdd = new EntityRelation(LineFields.DomainCode, CodeTypeFields.DomainCodeRangeStart, RelationType.OneToMany);
relationToAdd.CustomFilter = new PredicateExpression(new FieldBetweenPredicate(LineFields.DomainCode, null, CodeTypeFields.DomainCodeRangeStart, CodeType.DomainCodeRangeEnd));
relationToAdd.CustomFilterReplacesOnClause = true;
bucket.Relations.Add(relationToAdd);

Hope helpful.

David Elizondo | LLBLGen Support Team