Updating Entities

Posts   
 
    
polarbear
User
Posts: 5
Joined: 23-Oct-2006
# Posted on: 23-Oct-2006 22:45:45   

I'm new with LLBL and was wondering if someone could help me with a general question on what's the best way to update an Entity.

using LLBLGen 1.0.2005.1

just as an example, say i have the following entities (i hope i am illustrating the relationships clearly.. sorry if i'm not):

OrderEntity - OrderID - OrderDetailEntityCollection

OrderDetailEntity - OrderDetailID - OrderEntity - OrderDetailTypeEntity

OrderDetailTypeEntity - OrderDetailTypeID - OrderDetailTypeDescription

Now I have a webform that is used to modify the OrderDetails of a given OrderEntity. I am trying to basically collect all the changes made to the OrderDetails, before running a one time DataAccessAdapter.SaveEntity on the OrderEntity object.

Now I bind a DataGrid to the OrderDetailEntityCollection of the OrderEntity. When I 'Add' an OrderDetail, I want the user to be able to select the OrderDetailType from a DropDownList, fill in the other relevant info, and then I add a new OrderDetailEntity to the collection, and then rebind, without saving the actual OrderEntity yet. I can accomplish the actual adding of this new OrderDetailEntity fine, however, the problem is that after adding, I want the DataGrid to bind to and show the OrderDetailTypeDescription for each OrderDetailEntity, not the OrderDetailTypeID. Can someone tell me how I can accomplish this?

I may be approaching this all wrong... if anyone can help me out or point me to the right direction, it would be greatly appreciated. Thanks.

polarbear
User
Posts: 5
Joined: 23-Oct-2006
# Posted on: 23-Oct-2006 23:39:36   

In addition.. I was wondering if I wanted to do this in memory editing ability... how should I handle cases when the user wants to Delete the actualy OrderDetailEntity? Must I use some UnitOfWork of class to collect all the Deletes? This is kind of weird to me, because if I CREATE or MODIFY the OrderDetailEntities directly, those types of changes are handled by the DataAccessAdapter.SaveEntity(OrderEntity) function.. but deletes are not. So should I add ALL the create/modify/delete entities into the UoW to make it more consistent?

Thanks.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 24-Oct-2006 05:35:00   

The unit of work is more geared toward saving all database actions to be executed all at once. I would just use the in memory objects for inserts and updates and use the unit of work for deletes.