IsNull, and Using the same Table Twice.

Posts   
 
    
vash
User
Posts: 1
Joined: 17-Oct-2005
# Posted on: 17-Oct-2005 20:22:33   

I'm trying to generate a typed list that gives me the same result as

SELECT  
    PDA_Categories.ID, PDA_Categories.Name, 
    ISNULL(PDA_CategoryOverrides.PriorityID, PDA_Categories.PriorityID) AS PriorityID, 
    ISNULL(PDA_PriorityRatings.Name, PDA_PriorityRatings_1.Name) AS PriorityName,
    PDA_Categories.Description

FROM PDA_PriorityRatings PDA_PriorityRatings_1 INNER JOIN PDA_Categories ON
    PDA_PriorityRatings_1.ID = PDA_Categories.PriorityID LEFT OUTER JOIN 
    PDA_PriorityRatings INNER JOIN PDA_CategoryOverrides ON 
    PDA_PriorityRatings.ID = PDA_CategoryOverrides.PriorityID AND PDA_CategoryOverrides.ModuleID = 0 ON 
    PDA_Categories.ID = PDA_CategoryOverrides.CategoryID

But I can't see how to join on the same Table Twice, I'm also unsure how to do the same as an IsNull in LLBGen.

-jeremy

Drewes
User
Posts: 67
Joined: 18-Aug-2003
# Posted on: 18-Oct-2005 01:58:27   

For this type of query it is probably best to create a view and use that from llblgen as a typed view, that way you can use the exact query that you have now and still the advantages of using llblgen.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 18-Oct-2005 10:07:58   

To join an entity twice, just specify an alias for the entities, when you add the relation to the RelationCollection. The Add() method of the RelationCollection has overloads for this. See also the example of dynamic lists in the documentation for an example for this. For the IsNull methods, if you really need them, then a view is indeed a better option.

Frans Bouma | Lead developer LLBLGen Pro