Self join

Posts   
 
    
Mennisujay
User
Posts: 11
Joined: 25-Feb-2005
# Posted on: 23-Jun-2005 13:45:13   

hi Otis,

how can we crack self joins in Genpro ?

Thanks for immediate support for all our queries. simple_smile

Regards Sujay

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 23-Jun-2005 14:04:48   

in typed lists, by defining an alias in teh typed list editor, in filters by using the overload of RelationCollection.Add() which accepts aliasses for entities simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Mennisujay
User
Posts: 11
Joined: 25-Feb-2005
# Posted on: 24-Jun-2005 12:16:05   

hi Otis,

I have created a TypedList with fields I want with different alias names as that are in actual table. And I have used the following code

CustomerReminderTypedList customerReminderTypedList = new CustomerReminderTypedList();

RelationPredicateBucket bucket = (RelationPredicateBucket)customerReminderTypedList.GetRelationInfo();

bucket.PredicateExpression.Add(PredicateFactory.CompareValue( TblActivityFieldIndex.SzActivityStatus,ComparisonOperator.Equal,"Open"));

bucket.Relations.Add(TblActivityEntity.Relations.TblActivityEntityUsingGuReferenceId);

// here GuReferenceId is the column which is related to PK i,e GuActivityId

bucket.adapter.FetchTypedList(customerReminderTypedList.GetFieldsInfo(), customerReminderTypedList,bucket);

I got the follwing error

Tables or functions 'Elead.dbo.tblActivity' and 'Elead.dbo.tblActivity' have the same exposed names. Use correlation names to distinguish them.

Urgent help needed confused

Regards Sujay

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 24-Jun-2005 12:32:38   

In this line:


bucket.Relations.Add(TblActivityEntity.Relations.TblActivityEntityUsingGuReferenceId);

You should use an overload of Add() which accepts aliasses for both entities in the relation. simple_smile If you don't want to specify an alias, specify string.Empty.

Frans Bouma | Lead developer LLBLGen Pro
Mennisujay
User
Posts: 11
Joined: 25-Feb-2005
# Posted on: 24-Jun-2005 13:31:22   

hi Otis,

I am using

bucket.Relations.Add(TblActivityEntity.Relations.TblActivityEntityUsingGuReferenceId,"RefActivity");

I am able to get the records but only one set of columns, not the joined one. like for ex.

select a.guActivityId,b.guActivityId,a.guReferenceId,b.GuReferenceId, a.szType, b.szType from tblActivity join tblActivity b on guActivityId = b.GuReferenceId

here I am able to see both set of columns in result i,e. both 'a' and 'b'.

Can you plz help me out how can I get another set of column values also.

Urgent help is needed.

Regards Sujay

Mennisujay
User
Posts: 11
Joined: 25-Feb-2005
# Posted on: 24-Jun-2005 17:07:11   

hi Otis,

I haven't got answer for my above query, but my message was marked as completed.

Regards Sujay

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 24-Jun-2005 17:39:52   

Mennisujay wrote:

hi Otis,

I haven't got answer for my above query, but my message was marked as completed.

What does 'marked as completed' mean exactly? It's marked for review in my list, and it will be answered a.s.a.p.

Please keep in mind that everyone with a question needs answers on an urgent manner and probably can't continue before an answer is given.

Your question is answered a.s.a.p., the same as everybody elses questions.


To answer your question: In the typed list editor, add the entity TblActivityEntity twice, and give both a proper alias, then add for both aliasses the fields to the typed list. That should give you the fields for both aliassed entities.

This is what you tried and it didn't work?

Frans Bouma | Lead developer LLBLGen Pro