LINQ to SQL FAQ – Beware of the Trigger

I love triggers (and tiggers) but they can have nasty side-effects.

My current app has an issue logger with an Issues table and an IssueActivity sub-table. When trying to insert a new activity on an issue I was getting a "Row not found or changed" exception. Since both tables had timestamp columns it was really puzzling. I wrote a unit test, and traced the SQL being generated. Everything looked okay in the SQL, but the code failed when it ran.

Finally I stepped through the code checking what the in-memory classes had with the database version said, and noticed the timestamp on the Issue changed after I inserted the IssueActivity.

The cause was an insert trigger on IssueActivity that updated the Issue.ModifiedDate. This meant the timestamp on the database was modified, but the LINQ in-memory version was now out of date. It was essentially, doing its job.

The simple solution was to use db.Refresh(..) on the issue to tell it to reload the changed values.

Opinion – Chrome Revisited

Now Chrome’s been around a few weeks we can see some patterns. The first is that it’s share is slipping as people revert to FF/IE. That’s not too surprising, as you always get a launch "boost". But more worryingly for Firefox, it was they who lost share not IE. Which supports my hunch this would happen. What is unusual is that IE lost nearly 5% market share on September 6th and 7th. But not to Chrome, it would appear to have gone largely to Firefox! And then it got most of it back again on the 8th.

I’ve tried Chrome and I like it. It will make JavaScript-heavy web applications faster. But this is soon going to be an irrelevance.

The Net is moving on from Web 2.0 – it’s increasingly going to be Silverlight and Flash oriented. So "Web 3.0" is going to be much more like a desktop application – and the web browser that hosts Silverlight or Flash is pretty much irrelevant.

Opinion – Google Chrome

The first thing I thought when I heard about Google Chrome was "why?"

Let’s face it, we are not short of Browsers. Windows users have IE, Firefox, Opera and even Safari to name just the market leaders. Even Linux users have several to choose from. These guys are pretty stable, well featured and powerful. So Chrome isn’t really needed – in fact, Chrome will hurt competition by fragmenting the non-IE market.

Firefox is on version 3, stable, fast and a good alternative to IE – but it only has a smallish market share because most people are happy to use IE. Chrome won’t attack the IE market but it will potentially further compete in the non-IE market, which is not helpful to Firefox or Opera.

Looking at the features there isn’t anything really cool or radical in the feature set. The process-per-tab is interesting but not unique. Most of the others are found in other browsers.

The rationale for Chrome must therefore be internal to Google. V8 is a clue. Google has obviously been limited by JavaScript and wanted to push a more powerful browser-based scripting engine. I don’t think that is the real reason though.

I believe that Google understands that their entire business is controlled through and by the web browser. Which they have no control or influence over. Google also collects lots of information about our behaviour and preferences which they use, sell and exploit in pursuit of their business goals. At present that’s only the case when we are using Google’s applications – search, mail etc.

But if Google owns the browser as well, just think they can not only track what we search for, but everything we do on the browser – the links we click, the text we type etc. It isn’t currently part of Chrome that I am aware of, but if they get a substantial user base the temptation to add it will be become very powerful.