Linq To Sql, Attach, Using a DateTime as Timestamp and large bottle of ibuprofren!!!
Scenario: You use LINQ to SQL (L2S) as your ORM, you create a business layer that supplies a list of customer entities to the presentation layer. The UI presents the data in a gridview where the user can update the info. When the user clicks update, it passes a new instance of the entity to your BL method. Now you might be tempted to think that you simply use the Attach method of the Customers table and everythings fine and dandy. Oh that it were true. Be ready for: "System.InvalidOperationException: An entity can only be attached as modified without original state if it declares a version member or does not have an update check policy." The entity being passed to your BL here is *not* the same one that went out. It is a new one created by the GridView as part of the update. Thus, it has no idea of the original context and your new context has no idea of it's original state. If you have add a timestamp column that can be used by L2S to d...