Fetching collection based on unique constraint

Posts   
 
    
Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 07-Sep-2005 19:22:34   

Hello Fellow inmates,

I have a table with a UC of:

 1  SubjectAreaIdent    int 4   0
0   ClassRoomTchrIdent  int 4   0
0   SubAreaTchrIdent    int 4   0

I have an array that contains all three idents

 12,31,4
14,21,3
55,34,2

How can I fetch the collection in one go? I did not want to do a fetchentityUsingUC for each item an the array. I would rather fetch the whole thing into a collection.

Thanks,

Fishy

Paul.Lewis
User
Posts: 147
Joined: 22-Aug-2005
# Posted on: 08-Sep-2005 05:02:27   

Fishy wrote:

How can I fetch the collection in one go? I did not want to do a fetchentityUsingUC for each item an the array. I would rather fetch the whole thing into a collection.

Looking at the User Manual, I can't see a way to read by UC directly into a collection; only entity by entity.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 08-Sep-2005 10:14:17   

what exactly is the UC? the ident row? As I find the table description a bit confusing compared to the matrix you posted. simple_smile

Fetching a bunch of entities based on their uc values is best done with a FieldCompareRangePredicate: add all uc's to the range and use that for the filter.

Frans Bouma | Lead developer LLBLGen Pro
Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 08-Sep-2005 16:25:13   

Otis wrote:

what exactly is the UC? the ident row? As I find the table description a bit confusing compared to the matrix you posted. simple_smile

Fetching a bunch of entities based on their uc values is best done with a FieldCompareRangePredicate: add all uc's to the range and use that for the filter.

Sorry about the confusion, I copy/pasted the table from design mode in vs confused

The UC is the three ident fields: SubjectAreaIdent , ClassRoomTchrIdent, SubAreaTchrIdent

How would I construct the FieldCompareRangePredicate for those three idents and the corresponding three rows? I guess the where would look something like:

(SubjectAreaIdent =12 and ClassRoomTchrIdent=31 and SubAreaTchrIdent = 4) or (SubjectAreaIdent =14 and ClassRoomTchrIdent=21 and SubAreaTchrIdent = 3) or (SubjectAreaIdent =55 and ClassRoomTchrIdent=34 nd SubAreaTchrIdent = 2)

Thanks,

Fishy

[edit] none of the above idents are an ident for this table. These idents ar fks from other tables.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 09-Sep-2005 10:40:00   

if the UC is spanning multiple fields, then you're in for a set of AND predicate expressions indeed... There's no other way.

Frans Bouma | Lead developer LLBLGen Pro
Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 09-Sep-2005 16:28:40   

Yea, that's makes sense. Thanks. simple_smile