TypedList design to avoid multiple lists

Posts   
 
    
Posts: 254
Joined: 16-Nov-2006
# Posted on: 01-Apr-2007 22:19:42   

Guys,

I've attached a UML model of some tables which I am using together to create a TypedList. The typed list is called POThreadMessages and contains all message related to a specific Purchase Order. There is only one link table which links the PO entity to the Thread entity i.e.

POHeadConversationThread

and three core tables exist

ConversationThread ConversationMessage ConversationAttachment

However for other document types which have threads of conversation associated with them I currently have to create another typed list e.g. SIThreadMessages for supplier invoices. There must be a better way to design this so I can create one typed list e.g. ThreadMessages and apply a predicate to restrict the objects retrieved to only those from the associated POHead / SIHead table at runtime.

Thoughts please

Posts: 254
Joined: 16-Nov-2006
# Posted on: 01-Apr-2007 22:20:45   

I was going to attach the file with the screen shot however I don't have permissions to attach in this forum rage

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 01-Apr-2007 23:28:34   

MattAdamson wrote:

I was going to attach the file with the screen shot however I don't have permissions to attach in this forum rage

You have now simple_smile everyone can now add 1 attachment of 512KB. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Posts: 254
Joined: 16-Nov-2006
# Posted on: 01-Apr-2007 23:41:48   

I can't be everyone, I can't see any option to add an attachment.

Posts: 254
Joined: 16-Nov-2006
# Posted on: 01-Apr-2007 23:42:46   

Though I can do this in the data binding forum.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 02-Apr-2007 09:04:56   

MattAdamson wrote:

Though I can do this in the data binding forum.

Sorry, the role rights for users on this forum weren't adjusted. Users now have the right to attach a file to a post. Please re-connect to the forum.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 254
Joined: 16-Nov-2006
# Posted on: 02-Apr-2007 09:20:38   

Thanks files attached, any thoughts now?

Attachments
Filename File size Added on Approval
TypedListDesign.doc 25,088 02-Apr-2007 09:21.03 Approved
Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 02-Apr-2007 09:57:47   

You can create one TypedList of the following tables: ConversationThread ConversationMessage ConversationAttachment

And then at runtime you can filter on different joined tables, as follows:

Example #1:

WHERE ConversationThreadId IN
(SELECT  ConversationThreadID FROM POHeadConversationThread WHERE POHeadId = xx)

Example #2:

WHERE ConversationThreadId IN
(SELECT  ConversationThreadID FROM SupplierInvoicesConversationThread WHERE SupplierInvoicesId = yy)

Hint: use FieldCompareSetPredicate for the IN clause.

Posts: 254
Joined: 16-Nov-2006
# Posted on: 02-Apr-2007 10:52:31   

Thanks I will explore this predicate and try however will this still work if the joined entity is not included in the original typed list e.g. POHead.

Posts: 254
Joined: 16-Nov-2006
# Posted on: 02-Apr-2007 14:37:14   

This appears to work however would it not be more efficient to simply join on the table to restrict the results here so we join on the table and then create a predicate on a value on the joined table.

If this is the case how could we do this in code, i.e. which objects should we look at?

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 03-Apr-2007 09:48:28   

I don't which is more efficient, but if you want to join and filter on the joined table, then you should add a Relation (Join), and a PredicateExpression (Filter)

For Adapter: FetchTypedList() accepts a RelationPredicateBucket object in one of its overloads, in which you can find the Relations collection and the PredicateExpression object.

For SelfServicing: Use GetMultiAsDataTable() as follows:

MyTypedList myTL = new MyTypedList();
IRelationCollection relations = myTL.BuildRelationSet();
relations.Add(/*the needed relation*/);

TypedListDAO dao = DAOFactory.CreateTypedListDAO();
dao.GetMultiAsDataTable(myTL.BuildResultset(), myTL, 0, null, /*needed filter*/, relations, false, null, null, 0, 0);