<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-600691149406565027.post7897733935089089662..comments</id><updated>2009-10-29T13:56:35.243-05:00</updated><title type='text'>Comments on Brian Orrell: LINQ to SQL Updating in ASP.NET - The Right Way</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://borrell.parivedasolutions.com/feeds/7897733935089089662/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default?start-index=26&amp;max-results=25'/><author><name>Brian</name><uri>http://www.blogger.com/profile/04159127979776655125</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>27</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-1266532314217079027</id><published>2009-10-29T13:56:35.699-05:00</published><updated>2009-10-29T13:56:35.699-05:00</updated><title type='text'>Brian,

This is a great article and would really l...</title><content type='html'>Brian,&lt;br /&gt;&lt;br /&gt;This is a great article and would really like to test it out, however, the source code download link you provided seems to be broken.  Any chance you can revive it?&lt;br /&gt;&lt;br /&gt;Thanks!&lt;br /&gt;Justin</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/1266532314217079027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/1266532314217079027'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1256842595699#c1266532314217079027' title=''/><author><name>Justin</name><uri>http://www.justinkorn.com</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-8951206963068692819</id><published>2009-04-17T10:56:52.590-05:00</published><updated>2009-04-17T10:56:52.590-05:00</updated><title type='text'>Sam, the key thing is overriding the SaveViewState...</title><content type='html'>Sam, the key thing is overriding the SaveViewState and LoadViewState methods in your pages, otherwise, the serialization will fail.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/8951206963068692819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/8951206963068692819'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1239983812590#c8951206963068692819' title=''/><author><name>Brian</name><uri>http://www.blogger.com/profile/04159127979776655125</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='03189060312983890262'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-2152431197859535069</id><published>2009-04-10T20:36:04.179-05:00</published><updated>2009-04-10T20:36:04.179-05:00</updated><title type='text'>Brian,  what trick did you use to get the addresse...</title><content type='html'>Brian,  what trick did you use to get the addresses of the customer to serialize?&lt;BR/&gt;I downloaded your project, added my own context and a test page and I can serialize child entities for my tables in your project.&lt;BR/&gt;I copied your SerializerUtil class to my project, set the serialization mode of my context  to unidirectional but I cant get child entites to serialize.  &lt;BR/&gt;My project and yours point to the same database.&lt;BR/&gt;I verified that I am getting child entities back from my initial select.&lt;BR/&gt;Thanks,&lt;BR/&gt;&lt;BR/&gt;Sam</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/2152431197859535069'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/2152431197859535069'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1239413764179#c2152431197859535069' title=''/><author><name>sam</name><uri>http://www.blogger.com/profile/05247216756217793877</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-8051457200870226719</id><published>2009-04-10T16:23:43.081-05:00</published><updated>2009-04-10T16:23:43.081-05:00</updated><title type='text'>Thanks Sam. :)  You have to take the hit somewhere...</title><content type='html'>Thanks Sam. :)  You have to take the hit somewhere like you said (ViewState, Session, etc...) but many times, it is worth it for the user experience.&lt;BR/&gt;&lt;BR/&gt;As more client friendly means of holding on to state become mainstream (Silverlight, Flex, etc...) the "hit" will be less painful.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/8051457200870226719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/8051457200870226719'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1239398623081#c8051457200870226719' title=''/><author><name>Brian</name><uri>http://www.blogger.com/profile/04159127979776655125</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='03189060312983890262'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-1695825078474484135</id><published>2009-04-10T16:20:37.630-05:00</published><updated>2009-04-10T16:20:37.630-05:00</updated><title type='text'>You said ....this article also addresses the need ...</title><content type='html'>You said ....this article also addresses the need to add multiple children (all at once) rather than requiring the parent be saved first before children can be added. You have to use some form of temporary storage (whether Viewstate, Session, etc...) to maintain state while you are adding multiple children to a parent.&lt;BR/&gt;&lt;BR/&gt;Brian I think you and I are the only two coders on the planet who actually do this.  Let's not tell Microsoft it's a great way to create a friendly UI where the user can cancel out of changes.  &lt;BR/&gt;&lt;BR/&gt;Great article, thanks for sharing.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/1695825078474484135'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/1695825078474484135'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1239398437630#c1695825078474484135' title=''/><author><name>sam</name><uri>http://www.blogger.com/profile/05247216756217793877</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-3943837579046661914</id><published>2009-02-16T18:48:43.468-06:00</published><updated>2009-02-16T18:48:43.468-06:00</updated><title type='text'>Be careful when using session variables to persist...</title><content type='html'>Be careful when using session variables to persist the data (the same session variable which is what I was doing).  If the user opens multiple windows they will be walking all over each other.  For ex. if I load Bob's profile into session and then Jim's profile in a sep window - the session variable is for Jim's.  So if I save Bob's profile it will use Jim's profile data and write to the db (OOOPS).</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/3943837579046661914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/3943837579046661914'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1234831723468#c3943837579046661914' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-5901679889059939157</id><published>2009-02-15T11:45:26.014-06:00</published><updated>2009-02-15T11:45:26.014-06:00</updated><title type='text'>Is there some reason why you can't just call a sto...</title><content type='html'>Is there some reason why you can't just call a stored proc and let a DBA manage performance?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/5901679889059939157'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/5901679889059939157'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1234719926014#c5901679889059939157' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-5767891028804716535</id><published>2008-11-17T10:51:39.068-06:00</published><updated>2008-11-17T10:51:39.068-06:00</updated><title type='text'>ViewState does not have to be stored in the page. ...</title><content type='html'>ViewState does not have to be stored in the page.  There are many great examples out there of storing viewstate server-side only.&lt;BR/&gt;&lt;BR/&gt;The primary difference between ViewState and Session is the ability for state to be saved on a per-page basis which has its merits for the scenario described in the article.&lt;BR/&gt;&lt;BR/&gt;Totally agree that ViewState can become unwieldy and overly heavy from a network load perspective (if used the way it is setup out of the box).&lt;BR/&gt;&lt;BR/&gt;The point of the article is less about how to persist but rather how to rehyrdrate persisted objects for sending back to a services "tier".  LINQ to SQL missed the mark on making this scenario as straightforward as it could be.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/5767891028804716535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/5767891028804716535'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1226940699068#c5767891028804716535' title=''/><author><name>Brian</name><uri>http://www.blogger.com/profile/04159127979776655125</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='03189060312983890262'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-6220155312302094492</id><published>2008-09-25T13:50:23.263-05:00</published><updated>2008-09-25T13:50:23.263-05:00</updated><title type='text'>Why in the world are you using the ViewState?  As ...</title><content type='html'>Why in the world are you using the ViewState?  As one commenter mentioned, you are sending this information to the browser and back.  Not only does that effectively send the information twice, but it could end up sending information that you do not want available.  It also increases the size of the content stream that must be delivered to the client.&lt;BR/&gt;&lt;BR/&gt;It does seem like storing the object and reattaching it is the proper mechanism and is definetly helpful for pointing that out.  &lt;BR/&gt;&lt;BR/&gt;But it would seem that using the Session as the storage mechanism would be much more appropriate.  That way the object is solely on the server side.&lt;BR/&gt;&lt;BR/&gt;This is even more true if you want to use Ajax (whether you use ASP Ajax, YUI, jQuery, etc.) or Silverlight, etc. to do form submissions.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/6220155312302094492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/6220155312302094492'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1222368623263#c6220155312302094492' title=''/><author><name>thzero</name><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-3120785673255461839</id><published>2008-08-31T22:25:08.645-05:00</published><updated>2008-08-31T22:25:08.645-05:00</updated><title type='text'>Updated now.  Thanks.</title><content type='html'>Updated now.  Thanks.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/3120785673255461839'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/3120785673255461839'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1220239508645#c3120785673255461839' title=''/><author><name>Brian</name><uri>http://www.blogger.com/profile/04159127979776655125</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='03189060312983890262'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-5310475133531443295</id><published>2008-08-31T20:26:36.657-05:00</published><updated>2008-08-31T20:26:36.657-05:00</updated><title type='text'>Thank you Brian. Could you update the link for sou...</title><content type='html'>Thank you Brian. Could you update the link for source code.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/5310475133531443295'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/5310475133531443295'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1220232396657#c5310475133531443295' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-1516571869372192006</id><published>2008-07-29T10:01:26.861-05:00</published><updated>2008-07-29T10:01:26.861-05:00</updated><title type='text'>This was a very helpful article, as I encountered ...</title><content type='html'>This was a very helpful article, as I encountered the same issue. It would be cool if there was a way to set the concurrency mode, as there are times when you really do want it to commit the data is it is presented, and yes, the source may have been changed by something else during the process.&lt;BR/&gt;&lt;BR/&gt;In any event, I was able to resolve the issue by using stored procedures for the Insert and Update actions, then mapping the Insert and Update actions to those stored procedures in the LINQ to SQL dbml designer. Still not terribly pretty, but I do know what its doing now :) .</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/1516571869372192006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/1516571869372192006'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1217343686861#c1516571869372192006' title=''/><author><name>Kurt</name><uri>http://www.blogger.com/profile/08841929336155575573</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-3633946205049940953</id><published>2008-07-25T16:27:49.461-05:00</published><updated>2008-07-25T16:27:49.461-05:00</updated><title type='text'>Hi Brian,Thanks for a very good article. I think I...</title><content type='html'>Hi Brian,&lt;BR/&gt;&lt;BR/&gt;Thanks for a very good article. I think I understand both your main points (about the boolean values that need to be set to their original values before the Attach and about your approach to store the original object and use it for the Attach).&lt;BR/&gt;&lt;BR/&gt;However I'm not 100% sure about the timestamp. If I use your technique of storing the original object (and using it for the attach during the Save event), do I still need a timestamp? Doesn't seem that way to me but I may be overlooking something...&lt;BR/&gt;&lt;BR/&gt;PS to the group: I don't think newbie's solution of re-reading the db during the Save event will apply in a scenario where you want to load the original data from the db in the OnLoad event of an "Edit" page and then "watch for changes" while the Edit page is displayed to the user (i.e. if you want to use LINQ's optimistic concurrrency to find out whether the underlying data has changed since the user started editing the data on the form/page up to the point where the user clicks Save). In such a case I think Brian's proposed approach of storing the original object would work like a charm.&lt;BR/&gt;&lt;BR/&gt;Louis</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/3633946205049940953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/3633946205049940953'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1217021269461#c3633946205049940953' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-1664436327067052940</id><published>2008-07-21T05:23:24.109-05:00</published><updated>2008-07-21T05:23:24.109-05:00</updated><title type='text'>Definitely agree on the ViewState vs. the re-looku...</title><content type='html'>Definitely agree on the ViewState vs. the re-lookup.  For a basic update, it would make more sense to a do a re-select before updating rather than storing the original in viewstate.&lt;BR/&gt;&lt;BR/&gt;However, this article also addresses the need to add multiple children (all at once) rather than requiring the parent be saved first before children can be added.  You have to use some form of temporary storage (whether Viewstate, Session, etc...) to maintain state while you are adding multiple children to a parent.&lt;BR/&gt;&lt;BR/&gt;Good points.  We are all struggling with the "right" way to do this stuff and I'm sure we'll all be wrong in the long run. :)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/1664436327067052940'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/1664436327067052940'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1216635804109#c1664436327067052940' title=''/><author><name>Brian</name><uri>http://www.blogger.com/profile/04159127979776655125</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='03189060312983890262'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-5620005572581615345</id><published>2008-07-17T18:03:01.380-05:00</published><updated>2008-07-17T18:03:01.380-05:00</updated><title type='text'>So you would rather push the data via viewstate to...</title><content type='html'>So you would rather push the data via viewstate to the client browser, then have then client browser push it all the way back to you vs:&lt;BR/&gt;&lt;BR/&gt;1) Hit the db w/the *same context* for reinitialize&lt;BR/&gt;2) Update multiple cols (DB pages/extents come into play for the update but the overhead at that point is the lookup)&lt;BR/&gt;&lt;BR/&gt;Unless its a row with a ridiculous amount of cols I bet the serialize|deserialize is worse than the DB round trip for a single read (based on PK lookup). Kudos to the newbie on that one</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/5620005572581615345'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/5620005572581615345'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1216335781380#c5620005572581615345' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-8563767874646818056</id><published>2008-07-14T06:27:31.419-05:00</published><updated>2008-07-14T06:27:31.419-05:00</updated><title type='text'>Tim, unfortunately that is not the case.  Read the...</title><content type='html'>Tim, unfortunately that is not the case.  Read the post and you'll see why.  The rowversion property will not help you there.  The easiest way to see the problem is with boolean values.  If you are setting a value to false that was originally true, the datacontext will not register a change unless you set the value of the boolean value (to true) PRIOR to setting it to false after being attached.&lt;BR/&gt;&lt;BR/&gt;Row versions are for optimistic concurrency checking ONLY.  This is an issue I have confirmed with Microsoft, it's not solved with your solution.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/8563767874646818056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/8563767874646818056'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1216034851419#c8563767874646818056' title=''/><author><name>Brian</name><uri>http://www.blogger.com/profile/04159127979776655125</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='03189060312983890262'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-483613657361562702</id><published>2008-07-11T19:10:06.532-05:00</published><updated>2008-07-11T19:10:06.532-05:00</updated><title type='text'>Your solution is over engineer. According to MSDN ...</title><content type='html'>Your solution is over engineer. According to MSDN article on the Attach method "the entity is assumed to be in its original value state. After calling this method, you can then update its fields, for example with additional data sent from the client."&lt;BR/&gt;&lt;BR/&gt;Therefore, a better way to update data from an ASP.NET web page is&lt;BR/&gt;&lt;BR/&gt;DataContext db = new DataContext();&lt;BR/&gt;&lt;BR/&gt;Customer c = new Customer();&lt;BR/&gt;c.CustId = paramCustId&lt;BR/&gt;c.Version = ViewStateVersion&lt;BR/&gt;db.Customers.Attach(c);&lt;BR/&gt;c.comment = "some comments";&lt;BR/&gt;db.SubmitChanges();&lt;BR/&gt;&lt;BR/&gt;// Store the row version in view state.&lt;BR/&gt;ViewStateVersion = c.Version;&lt;BR/&gt;&lt;BR/&gt;The trick is to assign the customer entity with the original rowversion before attached it to the dataContext</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/483613657361562702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/483613657361562702'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1215821406532#c483613657361562702' title=''/><author><name>tim</name><uri>http://www.blogger.com/profile/15908997505099736664</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-5353098942972136077</id><published>2008-06-08T18:05:02.322-05:00</published><updated>2008-06-08T18:05:02.322-05:00</updated><title type='text'>Oops scratch that... it was a totally unrelated pr...</title><content type='html'>Oops scratch that... it was a totally unrelated problem :)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/5353098942972136077'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/5353098942972136077'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1212966302322#c5353098942972136077' title=''/><author><name>rei</name><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-4813667705832096611</id><published>2008-06-08T17:48:40.879-05:00</published><updated>2008-06-08T17:48:40.879-05:00</updated><title type='text'>It fails with an exception or it appears successfu...</title><content type='html'>It fails with an exception or it appears successful but doesn't update the value.  Are you using a timestamp column?&lt;BR/&gt;&lt;BR/&gt;What is Data.DC-- you should NEVER hold onto a datacontext.  It should be used and then disposed-- similar to a database connection.&lt;BR/&gt;&lt;BR/&gt;Do not cache your datacontext in a middle tier static or some such thing.  That is not the right approach.&lt;BR/&gt;&lt;BR/&gt;Have a look at my latest post on using a service tier if you want to have a separated business tier for updates.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/4813667705832096611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/4813667705832096611'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1212965320879#c4813667705832096611' title=''/><author><name>Brian</name><uri>http://www.blogger.com/profile/04159127979776655125</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='03189060312983890262'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-8278320400593631586</id><published>2008-06-08T17:44:11.910-05:00</published><updated>2008-06-08T17:44:11.910-05:00</updated><title type='text'>There must be a better way to do this.It's not eve...</title><content type='html'>There must be a better way to do this.&lt;BR/&gt;&lt;BR/&gt;It's not even anything to do with ASP.NET or Attach -- even if I do the same thing entirely in code by just updating a value, it'll refuse to update when the value is set to false.&lt;BR/&gt;&lt;BR/&gt;Am I missing something?&lt;BR/&gt;&lt;BR/&gt;This fails:&lt;BR/&gt;&lt;BR/&gt;Invoice inv = Data.DC.Invoices.Single(x =&gt; x.Id == id);&lt;BR/&gt;inv.IsActive = false;   //works only when setting to true&lt;BR/&gt;Data.DC.SubmitChanges();</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/8278320400593631586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/8278320400593631586'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1212965051910#c8278320400593631586' title=''/><author><name>rei</name><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-7764385402521251675</id><published>2008-05-28T18:20:14.915-05:00</published><updated>2008-05-28T18:20:14.915-05:00</updated><title type='text'>Responding to anonymous post on April 7:You can us...</title><content type='html'>Responding to anonymous post on April 7:&lt;BR/&gt;&lt;BR/&gt;You can use iqueryable to access a property such as Product.ProductName in an Eval.&lt;BR/&gt;&lt;BR/&gt;http://forums.asp.net/p/1262668/2377732.aspx#2377732&lt;BR/&gt;&lt;BR/&gt;-pugs421</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/7764385402521251675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/7764385402521251675'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1212016814915#c7764385402521251675' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-9065468218397922185</id><published>2008-04-14T07:41:24.763-05:00</published><updated>2008-04-14T07:41:24.763-05:00</updated><title type='text'>I've been searching for a simple yet functional ex...</title><content type='html'>I've been searching for a simple yet functional example of updating a row using LINQ to SQL from ASP.Net for a few days now, but yours is the only one that really makes sense to me.&lt;BR/&gt;&lt;BR/&gt;Thanks a lot for the info.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/9065468218397922185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/9065468218397922185'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1208176884763#c9065468218397922185' title=''/><author><name>Ian Dykes</name><uri>http://www.blogger.com/profile/08235675789374664427</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-7087314185078529981</id><published>2008-04-07T14:40:19.661-05:00</published><updated>2008-04-07T14:40:19.661-05:00</updated><title type='text'>This is exactly the reason I would use a standard ...</title><content type='html'>This is exactly the reason I would use a standard form and not use the DetailsView or FormView.  They are deceptively simple and then when you have a situation like you have with a foreign key lookup they take more time than if you used the method I outline in my post.  It's really not hard at all to do on your own with custom code.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/7087314185078529981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/7087314185078529981'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1207597219661#c7087314185078529981' title=''/><author><name>Brian</name><uri>http://www.blogger.com/profile/04159127979776655125</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='03189060312983890262'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-3710980279654773093</id><published>2008-04-07T14:33:13.278-05:00</published><updated>2008-04-07T14:33:13.278-05:00</updated><title type='text'>First off, Details view controls (and form view co...</title><content type='html'>&lt;I&gt;&lt;BR/&gt;First off, Details view controls (and form view controls for that matter) are pure evil. I have seen nothing but trouble from them.&lt;BR/&gt;&lt;BR/&gt;Be sure you are using a SQL Server 2005 Timestamp column, not a datetime field that you set as a timestamp. I couldn't tell from your post which you were using. Also, be sure you set your DataKeyNames property correctly in your data source control.&lt;BR/&gt;&lt;/I&gt;&lt;BR/&gt;&lt;BR/&gt;I am using a TimeStamp field on SQL Server 05 and I have my gridView's DataKeyName set to the PK of the table it is pulling from.&lt;BR/&gt;&lt;BR/&gt;Now that I've played around with it more I realize my problem is that I'm using a custom SELECTING statement for my LinqDataSource's SELECTING event.&lt;BR/&gt;&lt;BR/&gt;The reason for this is because for some reason the gridView won't display a field in a FK linked table (I have something like ProductID in my detailsView and I want to use the EVAL statment to display ProductName via Product.ProductName instead of just ProductID however, that always displays a blank field so I wrote a custom LINQ Selecting statement instead to just return the ProductName as part of the SELECT statement and display that in the detailsView).&lt;BR/&gt;So if I do NOT use the Selecting Event the update works fine now that I’ve added the TimeStamp field (thank you for that in your post).&lt;BR/&gt;But I’m still out of luck on how to do the update when I’m using the custom SELECTING LINQ statement (I really just wish my EVAL statement would work… but nothing is returned from that either…)&lt;BR/&gt;It is all most perplexing sadly…&lt;BR/&gt;Thank you again for your help (If you have any suggestions on how to solve this quandary I’d appreciate it greatly!)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/3710980279654773093'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/3710980279654773093'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1207596793278#c3710980279654773093' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-600691149406565027.post-5530123040772242987</id><published>2008-04-07T14:22:23.030-05:00</published><updated>2008-04-07T14:22:23.030-05:00</updated><title type='text'>First off, Details view controls (and form view co...</title><content type='html'>First off, Details view controls (and form view controls for that matter) are pure evil.  I have seen nothing but trouble from them.&lt;BR/&gt;&lt;BR/&gt;Be sure you are using a SQL Server 2005 Timestamp column, not a datetime field that you set as a timestamp.  I couldn't tell from your post which you were using.  Also, be sure you set your DataKeyNames property correctly in your data source control.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/5530123040772242987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/600691149406565027/7897733935089089662/comments/default/5530123040772242987'/><link rel='alternate' type='text/html' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html?showComment=1207596143030#c5530123040772242987' title=''/><author><name>Brian</name><uri>http://www.blogger.com/profile/04159127979776655125</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='03189060312983890262'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://borrell.parivedasolutions.com/2008/02/linq-to-sql-updating-in-aspnet-right.html' ref='tag:blogger.com,1999:blog-600691149406565027.post-7897733935089089662' source='http://www.blogger.com/feeds/600691149406565027/posts/default/7897733935089089662' type='text/html'/></entry></feed>