Tag Archives : ADO.NET


ADO.NET Data Services and Idempotence

I was reading thru the ADO.NET Data Services Quickstart, because I wanted to understand how it support data updates. The quickstart uses the Customers table from the Northwind sample database, which unlike most of the other tables uses an nchar(5) value as the primary key. Categories, Employees, Orders, Products, Shippers and Suppliers all use an auto-increment integer field for their primary keys.

I only point this out because inserting into Customers is idempotent, while inserting into those other listed tables is not. Is it a coincidence that the ADO.NET data services team chose the Customers table for their quickstart? Maybe, but I doubt it. Regardless, making a non-idempotent insert call from the browser is a bad idea, if you care about Exactly Once.


Morning Coffee 129

  • Short coffee this morning, as I’m home with a tweaked ankle.
  • I started playing Indigo Prophecy over the weekend. It’s an original Xbox game, released as part of the new Xbox Originals program. It has a good metacritic score (84), though apparently it wasn’t much of a retail success. I’m enjoying it, though it’s not very challenging. It’s more an interactive movie than a game. Good story, though.
  • The ASP.NET MVC preview dropped today, Scott Guthrie has the details. Scott Hanselman has a 40 minute how-to video and Phil Haack has severalarticles up already.
  • Speaking of ASP.NET MVC and Scott Guthrie, he’s got another post in his series on ASP.NET MVC. This time, he’s covering how to handle form input / POST data.
  • Erik Meijer has posted some of his thoughts on Volta. He’s one of the guys behind Volta, so it’s worth a good look. (via Dare Obasanjo)
  • Late Addition – the ASP.NET Extensions is more than just the MVC stuff. It also includes AJAX improvements, Silverlight support, ADO.NET Data Services and ASP.NET Dynamic Data Support. Data Services (formerly Astoria) let’s you easily expose your database via RESTful services. I think Dynamic Data Support used to be code named Jasper. It’s a “rich scaffolding framework” for ASP.NET. I assume that’s to compete w/ Ruby on Rails.

Morning Coffee 128

  • After using Outlook 2007 as my RSS reader for a few months, I’ve gone back to RSS Bandit. I run two work machines (desktop + laptop) and I finally got tired duplicated blog entries because each copy of Outlook downloads the same post. Also, for some reason Outlook downloads the same Technorati posts over and over again.
  • ADO.NET Entity Framework Beta 3 was released. The latest CTP of the EF Tools is also available. And as per the press release, EF has gained support from “Core Lab, DataDirect Technologies, Firebird Foundation Inc., IBM Corp., MySQL AB, Npgsql , OpenLink Software Inc., Phoenix Software International, Sybase Inc. and VistaDB Software Inc”. I’m not sure what that means, exactly, but I guess you’ll be able to LINQ to Entities on a wide variety of DB platforms. Interesting Oracle isn’t on that list. Not really surprising, but interesting.
  • Here’s a new ASP.NET MVC article from Scott Guthrie, this one on views and how you pass data to one from a controller. Using generics to get strongly-typed ViewData is pretty sweet. But where’s the MVC CTP that was supposed to be here this week?
  • In news about web app tool previews that did ship this week, Live Labs announces Volta. Haven’t installed or played with it yet, but I did read the fundamentals page. It primarily looks like a tool to compile MSIL -> JavaScript, so you can write your code in C# but execute it in the browser. Sam and Jesus are excited, Arnon not so much. Arnon’s argument that being able to postponing architectural decisions is to good to be true is fairly compelling, and not just because he quotes me to support his argument. But I’ll download it and provide further comment after I experiment with it myself.
  • Simple Sharing Extensions is now FeedSync. Not sure what else is new about it, other than it’s been blessed with “1.0″ status. The Live FeedSync Dev Center has an introduction, a tutorial and the spec. (via LiveSide)
  • Dare likes tuples. Me too. I also like symbols.

DataReaders, LINQ to XML and Range Generation

I’m doing a bunch of database / XML stuff @ work, so I decided to use to VS08 beta 2 so I can use LINQ. For reasons I don’t want to get into, I needed a way to convert arbitrary database rows, read using a SqlDataReader, into XML. LINQ to SQL was out, since the code has to work against arbitrary tables (i.e. I have no compile time schema knowledge). But XLinq LINQ to XML helped me out a ton. Check out this example:

const string ns = "{http://some.sample.namespace.schema}";

while (dr.Read())
{
    XElement rowXml = new XElement(ns + tableName,
        from i in GetRange(0, dr.FieldCount)
        select
            new XElement(ns + dr.GetName(i), dr.GetValue(i)));
}

That’s pretty cool. The only strange thing in there is the GetRange method. I needed an easy way to build a range of integers from zero to the number of fields in the data reader. I wasn’t sure of any standard way, so I wrote this little two line function:

IEnumerable<int> GetRange(int min, int max)
{
    for (int i = min; i < max; i++)
        yield return i;
}

It’s simple enough, but I found it strange that I couldn’t find a standard way to generate a range with a more elegant syntax. Ruby has standard range syntax that looks like (1..10), but I couldn’t find the equivalent C#. Did I miss something, or am I really on my own to write a GetRange function?

Update – As expected, I missed something. John Lewicki pointed me to the static Enumerable.Range method that does exactly what I needed.


Morning Coffee 100

  • The big 100. This puts be 1083 posts behind Iron Link Poster Mike Gunderloy. As his .NET skills deteriorate, maybe I can catch up…but I doubt it. I’m only 77 posts behind Sam Gentile, so maybe that’s a bit more feasible. 
  • The ADO.NET Team blog announces the new Entity Framework CTP. Looks like there’s also a new .NET Framework 3.5 CTP and new Visual Web Developer “Orcas” Express CTP as well. (via Sam Gentile)
  • Speaking of “Orcas” VS 2008, it launches with Windows Server 2008 and SQL Server 2008 next February. (via DNK)
  • Scott Guthrie continues is LINQ to SQL series. This time, using LINQ to SQL to update the database.
  • My friend Arvidra Semhi recently moved and rebooted his blog. Among his many accomplishments, Arvindra started the Architecture Journal. I’m particularly interested in his recent Service Capsule work. Subscribed.
  • Last night was the Microsoft E3 Briefing. Gamerscore blog has the news rundown. Didn’t seem to be any HUGE news. Last year’s E3 was the first Halo 3 showing and X06 featured the Halo Wars announcement. Nothing that earth-shaking this time, though the XBLM keeps on rolling, now featuring Disney movies. (Major Nelson has a list.) I’m thinking that the whole HD-DVD vs. BluRay war is going to be eclipsed by direct download before it’s over, though I’m still waiting for PC support & all-you-can-eat pricing.
  • Politics 2.0 Watch: Clay Shirky has a great blog post on modern-day Luddites. As he points out: “A Luddite argument is one in which some broadly useful technology is opposed on the grounds that it will discomfort the people who benefit from the inefficiency the technology destroys.” How much inefficiency is there in our modern political system? And more importantly, who benefits from that inefficiency? We’ve already seen the dramatic effects blogs can have on political news, media and reporting. What happens when users citizens are no longer satisfied just writing about the political process and want to get their hands dirty in the policy-making process itself?