typed view filter in join help?

Posts   
 
    
Posts: 24
Joined: 24-Jan-2005
# Posted on: 22-Jun-2005 13:12:40   

Hello

I would like to do this:

SELECT [dbo].[Language].[Name] AS [Name], [dbo].[Language].[ID] AS [LanguageID], [dbo].[Words].[ID] AS [WordsID], [dbo].[Words].[Default] AS [Default] FROM ( [dbo].[Language] LEFT JOIN [dbo].[Words] ON [dbo].[Language].[ID]=[dbo].[Words].[Language] and [dbo].[Words].[Category] = 35)

where the 'where' as it were is in the join rather than on the whole query. I want ALL the languages to be returned, but the joining words to only be matched when they have a specific category.

Is this possible?

Thank you! Mike

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 22-Jun-2005 14:01:25   

Yes, please see 'Custom filters for EntityRelations' in 'Using the generated code -> adapter/selfservicing -> filtering and sorting'.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 24
Joined: 24-Jan-2005
# Posted on: 22-Jun-2005 15:36:31   

Brill, thanks..

Posts: 24
Joined: 24-Jan-2005
# Posted on: 22-Jun-2005 16:24:51   

Hello,

I have tried that, but the thing is that i am returning details from two tables, so if i use a collection with a relation then when i try to retrieve the words from each language in the collection the relation is lost and i am back to the beginning. If I use a typed list then I don't see where to add in the custom relation?

Mike


EDIT: Will try a dynamic list

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 22-Jun-2005 16:41:16   

mikeydelamonde wrote:

Hello,

I have tried that, but the thing is that i am returning details from two tables, so if i use a collection with a relation then when i try to retrieve the words from each language in the collection the relation is lost and i am back to the beginning. If I use a typed list then I don't see where to add in the custom relation? Mike

If you're returning data combined from 2 entities, you can't use an entity collection, you've to use either a dynamic list or a typed list.

A dynamic list requires you to formulate the relationcollection so you can then add the predicate when you add the relation.

In a typedlist this is a bit difficult. In Adapter, it's not that hard: RelationPredicateBucket bucket = myTypedList.GetRelationInfo(); bucket.Relations[index].CustomFilter = ...;

then, pass bucket to FetchTypedList().

In SelfServicing, you've to derive a class from the TypedList class and override BuildRelationSet() and in there call the base.BuildRelationSet() and set the CustomFilter of the proper relation to the predicate you want.

You can also add the code to the usercode region in BuildRelationSet in the typed list class.

Frans Bouma | Lead developer LLBLGen Pro