Generating a Join without a Relationship

Posts   
 
    
mattcole
User
Posts: 15
Joined: 25-May-2006
# Posted on: 02-Jun-2006 04:44:11   

Hi, I have a table like : CREATE TABLE [ProductCategory] ( [ProductCategoryID] [int] IDENTITY (1, 1) NOT NULL , [ProductCategoryName] [varchar] (200) NOT NULL , [ProductCategoryDescription] [varchar] (500) NULL , [ProductCategoryHierachyID] [varchar] (100) NULL )

and without going into too much detail I need to generate a query like this (it returns a hierachy of categories):

select p2.productCategoryID from productcategory p join productcategory p2 on p2.productcategoryhierachyid like p.productcategoryhierachyid + cast(p.productcategoryid as varchar) + '%' where p.productcategoryid = @SomeID

My question is, as there is obviously no relationship able to be defined along the lines of the filter specified in the Join clause, is there anyway to get LLBLGen to produce this query for me? Is there anyway to get a table to join to itself without having defined a relationship?

Thanks, Matt

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 02-Jun-2006 07:33:16   

You may define a relation in the code between a table and itself. Add a relation to the relationPredicateBucket relations property, and use an alias for the end entity.