TypedList with 2 or more columns referring same entity

Posts   
 
    
JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 30-Dec-2009 22:25:38   

Hi,

I am using 2.6, SelfService. I want to use a typed list.

I have a base entity EmployeeSchedule with the following columns:

Id IdFirstShift IdSecondShift IdThirdShift StartDate

I have a second entity Shift holding the shiftdata with the following columns:

Id Name ... ...

I want to create a TypedList with the following columns:

IdEmployeer = EmployeeSchedule.Id FirstShiftName = Shift.Name related to IdFirstShift SecondShiftName = Shift.Name related to IdSecondShift ThirdShiftName = Shift.Name related to ThirdShiftName

I tried defining a TypedList by adding three Shift entities and then giving each an alias:

FirstShift, SecondShift and ThirdShift

but I cannot get the relations to refer to different Shift entities.

Is it possible to create a typed list like this or should I use an SQL view in combination with a TypedView?

Best regards,

Jan

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 31-Dec-2009 02:21:06   

Hi Jan,

You can with alternative relations. This is quoted from the manual:

If an entity has more than one relation with another entity in the typed list, you will be able to select an alternative relation for the currently selected relation. By clicking the set button, the then selected alternative relation is used instead of the current selected relation. To be able to specify how the relations should be joined in SQL, you can specify a join type per relation: None (default, results in inner join), left, right, cross or inner. Be aware that a cross join can be performance intensive.

David Elizondo | LLBLGen Support Team
JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 04-Jan-2010 17:22:44   

Hi David,

I tried that, but the result was that all three shifts kept referring to the same instance. The problem is that it is the same relation that is being used, but one employee record refers to three shift records.

I solved it by using a SQLServer view. You do not have to use a join but can use something like:

Select Id, IdShift1, NameShift1 = (Select Name from Shift where Id = IdShift1) IdShift2, NameShift2 = (Select Name from Shift where Id = IdShift2) etc.

Works fine. I do not think something like that can be done in a typed list.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Jan-2010 04:08:30   

Glad you found a workaround. Nevertheless if the relations exist in DB you should be able to use them as alternative relations in your typedList. If you want we take a closer look, attach your DDL and your lgp (llblgen project). You can do it in a Helpdesk thread which is private.

David Elizondo | LLBLGen Support Team