views:

193

answers:

2

In order to assist users with repetitve data entry, I am trying to implement a system where many of the previous properties are remembered when adding new data.

Is it possible to use the Properties.Settings.Default.MySetting functionality or is there a better method for doing this kind of thing?

A: 

Couldn't you just make a (deep) copy of the previous object, and use that as the next object, allowing users to overwrite any fields that changed? This way, the fields would be what the user last entered, individualized per user, and updated as they chnaged those fields.

If you have a way of remembering the last thing entered per user, you cold even preserve this between sessions.

The OP comments:

Unfortunately, making a deep copy of an object messes up the objectcontext when relationships are involved. A new object with relationships either needs to have new relational objects created or existing objects queried from the database.

So? If the relation is to an another entity (a foreign key in the database), it's a uses-a relationship, and you just retain it. If it's an attribute, you copy it.

For example, lets say your form is data entry about employees, and ithas a drop down for, I dunno, employeeType, that's either "Exempt" (no overtime) or "Non-exempt" (gets overtime). You pulled the values for employeeType from the database, and you want the next employee entered to have the same values as the last entered employee, to save the data entry people keystrokes. So your deep copy would just associate the copied employee with the same database employeeType.

But for attribute data (like name), you'd make a copy.

tpdi
Unfortunately, making a deep copy of an object messes up the objectcontext when relationships are involved.A new object with relationships either needs to have new relational objects created or existing objects queried from the database.
Damien
A: 

It depends on what you're trying to achieve. The good thing about using the MySetting functionality is that the "Most Recent" properties can be persisted the next time the application is closed.

I'm assuming this is a winforms application so I'd possibly keep a cached instance of the last save of each of the backing objects in a hashtable somewhere and then when you create a new form, look up the backing object in the hashtable and bind the required properties to the new instance of the form.

You can then serialize and persist the entire hashtable to the MySettings object if you like so it can be used each time the user accesses the application.

lomaxx