1:n Object Retrieval Question

Posts   
 
    
tlyle
User
Posts: 8
Joined: 14-Jan-2005
# Posted on: 12-May-2005 17:29:35   

I am using the SelfServicing model, and am having trouble figuring out how to follow the object tree to retrieve a child entity in a 1:n relationship.

Take the following example: ProspectEntity: PK - CustomerID ProspectContactEntity: PK - CustomerID, OrderID

I fetch the Prospect Entity, and fill a grid using the Prospect.ProspectContact collection. When a user clicks on a specific contact row, I want to then present them with the contact details.

I would like to be able to retrieve this object via the collection. How would I accomplish this?

I am currently creating a new Entity and fetching it using the CustomerID, and OrderID. My problem with this is when the user updates information in the "New" Entity, the collection no longer reflects the "current" entity. The only way I can find to reference an entity in the collection is by using Index. But information in the grid does not have an Index, so I don't have a way point back to the entity.

Thanks for the help, and sorry for what is probably and amateur question.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 13-May-2005 11:34:24   

tlyle wrote:

I am using the SelfServicing model, and am having trouble figuring out how to follow the object tree to retrieve a child entity in a 1:n relationship.

Take the following example: ProspectEntity: PK - CustomerID ProspectContactEntity: PK - CustomerID, OrderID

I fetch the Prospect Entity, and fill a grid using the Prospect.ProspectContact collection. When a user clicks on a specific contact row, I want to then present them with the contact details.

I would like to be able to retrieve this object via the collection. How would I accomplish this?

WHen the user clicks on a row, you can determine the row index of the row in the grid, and with that the object selected with that row. (depends on the grid how this is done). The object you then get is a ProspectContactEntity. So you can then use that object to fetch the order object, by simply calling its field mapped onto that relation, for example 'Order', as the lazy loading will fetch that for you.

Frans Bouma | Lead developer LLBLGen Pro
tlyle
User
Posts: 8
Joined: 14-Jan-2005
# Posted on: 18-May-2005 22:22:27   

Thanks for the reply. I had thought about using a row number, but until testing based upon your sugession, I did not realize that the row "index" was associated with the datasource.

The grid we are using is sortable on the client side in ASP.NET, and I had assumed that the "index" would return the currently selected row, not the row in the datasource. Great to know this.

Thanks!