OT: Code Generation & Advice on Editing Domain tables

OT: Code Generation & Advice on Editing Domain tables

Old forum URL: forums.lhotka.net/forums/t/2239.aspx


mr_lasseter posted on Tuesday, January 30, 2007

 

First the advice, I am creating an winForms application that allows the users to update some of the domain tables in the application.  I do this by displaying a read only collection of all the items in a datagridview.  On this form the user can click an edit or add button which will display the appropriate edit window with that object.  My question is once the user makes the changes to the object in the edit window I need to reflect these changes in the datagridview.  I know I could simply refresh the list by pulling all the information into the database, but this seems like overkill since some of the tables will contain thousands of records and I can't see updating the list with that many records for changes in one record. 

My question is should the readonly collection know how to add/update records based on its editable coutner part?  Or should the UI be responsible for updating/adding the new record to the list?


Next question involves code generation with partial classes.  How are you handling compisition in your code generated classes?  How are you handling ValidationRules that don't depend on the  database constraints? 

Thanks in advance.

Brian Criswell replied on Tuesday, January 30, 2007

Add an update method to the read only item that takes the editable object and updates its fields.  Then the UI can use the editable object if the user saved the changes.

public void Update(EditableObject item)
{
    // Update fields
}

Copyright (c) Marimer LLC