riceboyler.NET

The blog of the riceboyler, a boost-lovin', kid huggin', code writin', boogersmoocher...

LINQ to SQL: Don't use a Static DataContext

I’ve had this weird bug happening with one of the first apps I wrote using LINQ to SQL, and today, I think I figured out why.  The error has been really random, but always involved in importing data into it.  In this case, they were trying to import Spot (TV Commercial) data into the database, and they kept getting my least favorite LINQ error of all time: “Row not found or changed.”  (Seriously, couldn’t we get something a LITTLE more expressive as an error?  But I digress…)

So today, I decided I would run a SQL Server Profile on it, and trace what was getting thrown at the database.  Glad I did, as I found out that at the end of it trying to insert 10 SPOT records into the database, it was trying to update a CALL (as in telephone call) record repeatedly.  WHY?

Then, I looked at the underlying code, and realized I was using a static DataContext from a Global class.  The problem appears to be that the update never completed, and so anytime I called the SubmitChanges() method on that static DataContext, it was still trying to update the database, and failing.

So, lesson learned?  Don’t use static DataContexts, as they’ll cause you lots of pain and consternation.


The Passing of a Legend: Dan Miller

6a00d8341cbd4a53ef00e55008367c8834-150wi[1] Strangely, I have found myself really emotional distraught following the passing of Dan Miller, long-time anchor at WSMV (Channel 4) in Nashville.  I didn’t grow up in Nashville, but he still felt like a friend from the time I arrived here.

I’ve spent the last few hours poring over his blog (http://danmiller.typepad.com/) and coming to an even greater appreciation and recognition not for his talent as a broadcaster, but for his understanding of life and priorities. He posted about many varied topics, I’m sure whatever was on his mind that day, and reading his thoughts has helped me realize what his legacy is.  He was just a darn good man.  One of the things that many of his work associates have said about him is that he was just a down-to-earth guy who had no sense of “stardom” about him.  That is more than borne out in his blog.

I have also come to realize (with the passing of legendary Phillies announcer Harry Kalas) that I take the deaths of broadcasters somewhat personally.  It probably has something to do with my years in radio, and that yearning in the back of my heart to return to broadcasting in some way.  So, today I say good-bye to a friend that I never met.  While I feel for your family, I think the fact you were able to pass on while taking a walk with your good friend in your hometown demonstrates God’s mercy.

We’ll miss you Dan.


PhotoStream

Calendar

<<  July 2010  >>
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

TwitterFeed

Follow @Zune for the latest music news & cool giveaways! -> I want a free Zune Pass!
Wednesday 3:00PM
It's fun looking up @nashvillesounds trivia for giving away tickets today. Learning more than I thought I would want to know. :)
Wednesday 12:46PM
@BreanneDuren Why not just start up a blog on your own site? If not, tumblr.com is a great place for musicians!
Wednesday 12:40PM
And thus begins the end of my listening to @3hourlunch1045 -> RT @ClayTravisBGID We're broadcasting live from Neyland Stadium today.
Wednesday 7:55AM
@jeffblankenburg NERD ALERT!!! Hope the Boot Camp went well, wish I could have been there.
Tuesday 3:35PM
@eazye187 That last one was at you. Tools > me. #fail
Tuesday 2:57PM
Don't know that we are, for certain, yet.
Tuesday 2:56PM
RT @keithelder I need a ticket to #DevLink for a team member. If someone isn't able to attend, let me know. Thanks.
Tuesday 2:50PM
@eazye187 You may well get both of them back if we likewise move. :) Either way, no problem. I appreciate being able to use them.
Tuesday 2:44PM
@eazye187 Oh, absolutely. Great tracks out there.
Tuesday 2:26PM
Follow me on Twitter

RecentComments

Comment RSS