Help with EntityCollection

Posts   
 
    
G.I.
User
Posts: 172
Joined: 09-Jun-2005
# Posted on: 27-Oct-2005 16:02:06   

Hi,

I have so far only programmed Self Servicing, now I am programming Adapter, which I find actually even better to use, since it provides a little better layer structure, since the entities don't have CRUD methods anymore.

It also provides me with a little more structured code, since I really have to fetch the data I need programmatically. With selfservicing it can be done use lazyloading. Which is very easy to program, but it tends to be too unpredictable, but that's probably me coding this.

Anyway, I find a lot of things very easy to to, with the buckers, transaction etc. The only problem I have run into is what to do with Collections.

I used to have a ProjectEntity which had a collection of ProjectTasks as a property.

So I could easily say Project.ProjectTask[0].TaskNo to get my task no of the first projecttask.

With adapter I don't really know how to work with this...

There are two things I used to do with collections. Keep them as a child of an entity, like Project and ProjectTasks and I use to have them as single collection object, for example a collection ServiceLines.

These servicelines I could just call fill them using a filter and I had a collection filled with ServiceLine Entities which was of type ServiceLineCollection.

In adapter I just have an entity collection. My problem is now: How do I know which type it is, or do I always have to say: (ServiceLineEntity)ServiceLineCollection[0] to get the first ServiceLine?

And also: If I have a Project with ProjectTasks, how do I do: txtTaskNo = Project.ProjectTask[0].TaskNo in adapter code? Since it's not a typed collection?

I also want to know how to use a stand alone collection. I mean, I can fill it with adapter, using a filter. But how do I know WHICH entities I am filling it with and do I declare it as an EntityCollection and have to convert it all the time to the correct entity?

Please help me...

Gr.,

G.I.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 27-Oct-2005 16:25:34   

So I could easily say Project.ProjectTask[0].TaskNo to get my task no of the first projecttask. With adapter I don't really know how to work with this...

((ProjectTaskEntity)Project.ProjectTask.Items[0]).TaskNo

In adapter I just have an entity collection. My problem is now: How do I know which type it is, or do I always have to say: (ServiceLineEntity)ServiceLineCollection[0] to get the first ServiceLine?

Yes, I'm afraid you will have to typecast.

And also: If I have a Project with ProjectTasks, how do I do: txtTaskNo = Project.ProjectTask[0].TaskNo in adapter code? Since it's not a typed collection?

txtTaskNo = ((ProjectTaskEntity)Project.ProjectTask.Items[0]).TaskNo

I also want to know how to use a stand alone collection. I mean, I can fill it with adapter, using a filter. But how do I know WHICH entities I am filling it with and do I declare it as an EntityCollection and have to convert it all the time to the correct entity?

You can pass the EntityClassFactory in the constructor of the Entity Collection, to fetch the needed Entities.

Good Luck