Update typedlist during transaction

Posts   
 
    
Dominique
User
Posts: 22
Joined: 13-Sep-2005
# Posted on: 15-Sep-2005 12:38:28   

Hello,

here's my next question. smile

I have a form which contains a grid that is populated with a typedlist because it shows 2 joined tables. The user can update the records using buttons on the screen. When the user clicks the delete for instance, I get the key of the record out of the typedlist, create a entity with the primary and update that entity.

The user can do this multiple times on the form and the changes are only saved to the database when he presses the ok button, therefore, I'm using a unitofwork to handle this, which works perfectly.

The problem I'm having, is when the user presses the delete, I perform the delete behind the scenes, which is not yet commited to the database, but I need the typedlist to be updated so that the deleted record does not show itself anymore in the list. I've found a way to do this if the grid is displaying an entitycollection using the removeat, is there a way I can do this with a typedlist. The same for changing a record ? confused

Thx, Dominique.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 15-Sep-2005 14:43:56   

You could remove rows from a typedlist, that should solve the problem I think. A typedlist is marked readonly, you probably have to set the readonly properties to false again before being able to remove a row from the typedlist (a typedlist is a datatable, so removing rows works the same as with a datatable).

Frans Bouma | Lead developer LLBLGen Pro
Dominique
User
Posts: 22
Joined: 13-Sep-2005
# Posted on: 15-Sep-2005 14:52:28   

Otis wrote:

You could remove rows from a typedlist, that should solve the problem I think. A typedlist is marked readonly, you probably have to set the readonly properties to false again before being able to remove a row from the typedlist (a typedlist is a datatable, so removing rows works the same as with a datatable).

Ok, but what can I do with newly added items or items that are modified, can I make them visible?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 15-Sep-2005 15:24:57   

Dominique wrote:

Otis wrote:

You could remove rows from a typedlist, that should solve the problem I think. A typedlist is marked readonly, you probably have to set the readonly properties to false again before being able to remove a row from the typedlist (a typedlist is a datatable, so removing rows works the same as with a datatable).

Ok, but what can I do with newly added items or items that are modified, can I make them visible?

A typedlist is really for readonly data, displayed as a list. If you want to fully work on the resultset, I'd suggest to use an entitycollection. To have fields from related entities in your entity (for example you want to show/work on a list of orders and you want to show the Customer.CompanyName as well), you'd use Fields mapped onto related fields, in my example you'd map Customer.CompanyName in the order entity (in the order entity editor).

Fetching the collection is then done using a prefetch path: fetch the orders and the related customers. Saving is simple, just save recursively.

Frans Bouma | Lead developer LLBLGen Pro