How to convert this query to use predicates...

Posts   
 
    
CGLock
User
Posts: 17
Joined: 03-Jun-2007
# Posted on: 17-Aug-2007 21:14:55   

Could someone give me a little assistance in creating the correct predicates needed for the following query?

select a.NeighborhoodModelOptionId, a.OptionId, b.NeighborhoodId, d.Name as NeighborhoodName, b.NeighborhoodModelId, c.ModelId, c.Name as ModelName, a.OptionTypeCode, a.Price, a.IsActive from NeighborhoodModelOption a right outer join NeighborhoodModel b on a.NeighborhoodModelId = b.NeighborhoodModelId and (a.OptionId = 'b0c6133f-0f03-4a10-a82b-9cfd8166257b' or a.OptionId is null) inner join Model c on b.ModelId = c.ModelId inner join Neighborhood d on b.NeighborhoodId = d.NeighborhoodId where b.IsActive = '1' and b.NeighborhoodId = '53f0def5-4b8b-4b84-8a10-11c6471b6f15'

CGLock
User
Posts: 17
Joined: 03-Jun-2007
# Posted on: 19-Aug-2007 17:27:53   

The following code returns the resultset I am looking for, is there any way to remove the "DISTINCT" out of the select statement?

        rels.Add(NeighborhoodmodeloptionEntity.Relations.NeighborhoodmodelEntityUsingNeighborhoodModelId, JoinHint.Right)
        rels(0).CustomFilter = New PredicateExpression(NeighborhoodmodeloptionFields.NeighborhoodModelId = NeighborhoodmodelFields.NeighborhoodModelId)

        rels(0).CustomFilter.AddWithAnd(New PredicateExpression(NeighborhoodmodeloptionFields.OptionId = "b0c6133f-0f03-4a10-a82b-9cfd8166257b" Or _
               NeighborhoodmodeloptionFields.OptionId = DBNull.Value))

        rels.Add(NeighborhoodmodelEntity.Relations.ModelEntityUsingModelId, JoinHint.Inner)
        rels.Add(NeighborhoodmodelEntity.Relations.NeighborhoodEntityUsingNeighborhoodId, JoinHint.Inner)

        filter = NeighborhoodmodelFields.IsActive = "1" And NeighborhoodmodelFields.NeighborhoodId = "53f0def5-4b8b-4b84-8a10-11c6471b6f15"
        col.GetMulti(filter, rels)
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Aug-2007 20:31:04   

As you are retrieving Fields of multiple entities, you must use a Dynamic List. Then you can indicate allowDuplicates=true that will result in a SELECT without DISTINCT. Please read LLBLGenPro Help - Using generated code - SelfServicing - Using TypedVies, TypedLists and Dynamic List - Using dynamic lists.

David Elizondo | LLBLGen Support Team