What would be considered best practice for updates when using LINQ:
- To have an instantiated db/facade object, and submit all changes to a record in one go?
- To have a static db/facade object, and submit changes cell by cell?
Right now I'm in a project where each cell for a record has its own static update method
public static void CellName(int id, int data)
{
using (var scope = new someDataContext())
{
var TableName = scope. CellName.Single(v => v.ID == id);
TableName.CellName = data;
scope.SubmitChanges();
}
}
These can then be set as a property in a business object, following the usual TableName.CellName = [something]
scheme.
But I've also done projects where we've used an instantiated db/facade class. Where you first set the new values like properties and then call a database.SubmitChanges()
method which then does the update for the entire record (or records).
From a design perspective, I like the first option better - when a property is set, the changes are instantaneous, and it's treated like any other object. But from a technical perspective, I suspect there's performance to be gained by doing updates in bulk.
So which method should I chose - or is there other options I should consider?