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
Showing posts from December, 2007
- Other Apps
There is a simple fix for when the Linq to Sql designer goes crazy with the number of points on an association line. Simply close the designer, click "Show All Files" in your solution. You should now be able to expand the underlying files used to store info for the designer. Open the dataContextName. dbml.layout file with the XML Editor. Associations are stored in an associationConnector element. Find the correct association and change the following attributes to appear as follows: manuallyRouted="false" fixedFrom="NotFixed" fixedTo="NotFixed" If manuallyRouted doesn't appear, don't worry about it. Save everything and close the file. Reopen the designer and your line still looks weird but as soon as you move one of the objects around, it should fix itself.
- Other Apps
Went to STL for the Rams-Steelers game. As we we're driving to the hotel, you'd have thought it was a home game. There were more Steeler nation than Rams fans by far. If you ever want to see a site, Casey Hampton was stretching in front of us. At one point he was doing the exercise where you bring your knee across your body and try to touch it to the ground. You must see it for yourself! Alan Fanaca was also stretching and didn't seem to want to talk. Wish him the best next year. He's given a lot to the team over the years and deserves to get a great contract. Forget the hometown discount!!! The game was excellent! Didn't see Willie get hurt although I remember the play. The opening pass from Ben to Holmes was amazing. Need to work on our coverage. Is it just me, or does it seem that you can throw under DeShea pretty easily?!