Passion * Technology * Ruthless Competence

Monday, December 01, 2008

IronPython and Linq to XML Part 4: Generating XML

Now that I have my list of Rock Band songs and I can get the right Zune metadata for most of them, I just need to write out the playlist XML. This is very straight forward to do with the classes in System.Xml.Linq.

def GenMediaElement(song):
  try:
    trackurl = zune_catalog_url + song.search_string
    trackfeed = XDocument.Load(trackurl)
    trackentry = First(trackfeed.Descendants(atomns+'entry'))
    trk = ScrapeEntry(trackentry)
    return XElement('media', (XAttribute(key, trk[key]) for key in trk))
  except:
    print "FAILED", song
    
zpl = XElement("smil",
  XElement("head"
    XElement("title", "Rock Band Generated Playlist")),
  XElement("body",
    XElement("seq", (GenMediaElement(song) for song in songs))))

settings = XmlWriterSettings()
settings.Indent = True
settings.Encoding = Encoding.UTF8
with XmlWriter.Create("rockband.zpl", settings) as xtw:
  zpl.WriteTo(xtw)

XElement’s constructor takes a name (XName to be precise) and any number of child objects. These child objects can be XML nodes (aka XObjects) or simple content objects like strings or numbers. If you pass an IEnumerable, the XElement constructor will iterate the collection and add all the items as children of the element. If you’ve had the displeasure of building an XML tree using the DOM, you’ll really appreciate XElements’s fluent interface. I was worried that Python’s significant whitespace would force me to put all the nested XElements on a single line, but luckily Python doesn’t treat whitespace inside parenthesis as significant. 

Creating collections in Python is even easier than it is in C#. Python’s supports a yield keyword which is basically the equivalent of C#’s yield return. However, Python also supports list comprehensions (known as generator expressions), which are similar to F#’s sequence expressions. These are nice because you can specify a collection in a single line, rather than having to create a separate function, which is what you have to do to use yield. I have two generator expressions: (XAttribute(key, trk[key]) for key in trk) creates a collection of XAttributes, one for every item in the trk dictionary and (GenMediaElement(song) for song in songs) which generates a collection of XElements, one for every song in the song collection.

Once I’ve finished building the playlist XML, I need to write it out to a file. Originally, I used Python’s built in open function, but the playlist file had to be UTF-8 because of band names like Mötley Crüe. Zune’s software appears to always use UTF-8. In addition to setting the encoding, I also specify to use indentation, so the resulting file is somewhat readable by humans.

The playlist works great in the Zune software, but since it’s a streaming playlist there’s no easy way to automatically download all the songs and sync them to your Zune device. I expected to be able to right click on the playlist and select “download all", but there’s no such option. Zune does have a concept called Channels where the songs from a regularly updated feed are downloaded locally and synced to the device. However, the Zune software appears to be hardcoded to only download channels from the catalog service so I couldn’t tap into that. If anyone knows how to sign up to become a Zune partner channel, please drop me a line.

Otherwise, that’s So there you have it. As usual, I’ve stuck the code up on my SkyDrive. If I can remember, I’ll try and run the script once a week and upload the new playlist to my SkyDrive as well.

Posted By Harry Pierson at 11:13 PM Pacific Standard Time
IronPython | LINQ | Rock Band | XML | Zune

Thursday, November 27, 2008

IronPython and Linq to XML Part 3: Consuming Atom Feeds

Now that I have my list of Rock Band songs, I need to generate a Zune playlist. I wrote that Zune just uses the WMP playlist format, but that’s not completely true. Media elements in a Zune playlist have several attributes that appear unique to Zune.

Because of Zune Pass, Zune supports the idea of streaming playlists where the songs are downloaded on demand instead of played from the local hard drive. In order to enable this, media elements in Zune playlists can have a serviceID attribute, a GUID that uniquely identifies the song on the Zune service. We also need the song’s album and duration – the Zune software summarily removes songs that don’t include the duration.

Of course, the Rock Band song list doesn’t include the Zune song service ID. It also doesn’t include the song’s album or duration. So we need a way, given the song’s title and artist (which we do have) to get its album, duration and service ID. Luckily, the Zune service provides a way to do exactly this, albeit an undocumented way. Via Fiddler2, I learned that Zune exposes a set of Atom feed web services on catalog.zune.net that the UI uses when you search the marketplace from the Zune software. There are feeds to search by artist and by album but the one we care about is the search by track. For example, here’s the track query for Pinball Wizard by The Who.

Since these feeds are real XML, I can simply use XDocument.Load to suck down the XML. Then I look for the first Atom entry element using similar LINQ to XML techniques I wrote about last time. If there’s no Atom elements, that means that the search failed – either Zune doesn’t know about the song or it can’t find it via the Rock Band provided title and artist. Of the 461 songs on Rock Band right now, my script can find 417 of them on Zune automatically.

Of course, since the Zune data is in XML instead of HTML, finding the data I’m looking for is much easier that it was to find the Rock Band song data. Here’s the code pull the relevant information out of the Zune catalog feed that we need.

def ScrapeEntry(entry):  
  id = entry.Element(atomns+'id').Value 
  length = entry.Element(zunens+'length').Value 

  d = {} 
  d['trackTitle'] = entry.Element(atomns+'title').Value 
  d['albumArtist'] = entry.Element(zunens+'primaryArtist')
                       .Element(zunens+'name').Value 
  d['trackArtist'] = d['albumArtist'] 
  d['albumTitle'] = entry.Element(zunens+'album')
                       .Element(zunens+'title').Value 
   
  if id.StartsWith('urn:uuid:'): 
    d['serviceId'] = "{" + id.Substring(9) + "}" 
  else: 
    d['serviceId'] = id 
   
  m = length_re.Match(length) 
  if m.Success: 
    min = int(m.Groups[1].Value) 
    sec = int(m.Groups[2].Value) 
    d['duration'] = str((min * 60 + sec) * 1000) 
  else: 
    d['duration'] = '60000
     
  return

trackurl = catalogurl + song.search_string
trackfeed = XDocument.Load(trackurl) 
trackentry = First(trackfeed.Descendants(atomns+'entry')) 
track = ScrapeEntry(trackentry) 

A few quick notes:

  • The code above isn’t valid Python, I added a couple of carriage returns (albumArtist and albumTitle) to get it to read well on the blog without wrapping badly.
  • song.search_string returns the song title and artist as a plus delimited string. i.e. pinball+wizard+the+who. However, many Rock Band songs end in a parenthetical like (Cover Version) so I automatically strip that off for the search string
  • duration in the Atom feed is stored like PT3M23S, which means the song is 3:23 long. The playlist file expect the song length in milliseconds, so I use a .NET regular expression to pull out the minutes and seconds and do the conversion. It’s not exact – songs lengths usually aren’t exactly a factor of seconds, but as far as I can understand, Zune just uses that to display in the UI – it doesn’t affect playback at all.

Now I have a list of songs with all the relevant metadata, next time I’ll write it out into a Zune playlist file.

Posted By Harry Pierson at 10:55 AM Pacific Standard Time
IronPython | LINQ | Rock Band | XML | Zune

Wednesday, November 26, 2008

IronPython and Linq to XML Part 2: Screen Scraping

First, I need to convert the HTML list of Rock Band songs into a machine readable format. That means doing a little screen scraping. Originally, I used Beautiful Soup but I found that UnicodeDammit got confused on names like Blue Öyster Cult and Mötley Crüe. I’m guessing it’s broken because IronPython doesn’t have non-unicode strings.

Instead, I used SgmlReader to provide an XmlReader interface over the HTML, then queried that data via Linq to XML. I used the version of SgmlReader from MindTouch since they include a compiled binary and it seems to be the only active maintained version. I wrapped it all up in a function called load that loads HTML from either disk or the network (based on the URI scheme) into an XDocument.

def loadStream(streamreader):
  from System.Xml.Linq import XDocument
  from Sgml import SgmlReader
  
  reader = SgmlReader()
  reader.DocType = "HTML"
  reader.InputStream = streamreader
  return XDocument.Load(reader)
  
def load(url):
  from System import Uri
  from System.IO import StreamReader
  
  if isinstance(url, str):
    url = Uri(url)
  
  if url.Scheme == "file":
    from System.IO import File
    with File.OpenRead(url.LocalPath) as fs:
      with StreamReader(fs) as sr:
        return loadStream(sr)
  else:
    from System.Net import WebClient
    wc = WebClient()
    with wc.OpenRead(url) as ns:
      with StreamReader(ns) as sr:
        return loadStream(sr)

def parse(text):
  from System.IO import StringReader
  return loadStream(StringReader(text))

I call load, passing in the URL to the list of songs. The “official” Rock Band song page loads the actual content from a different page via AJAX, so I just load the actual list directly via my load function.

Once the HTML is loaded as an XDocument, I need a way to find the specific HTML nodes I was looking for. As I said earlier, XDocument uses Linq to XML – there is not other API for querying the XML tree. In the HTML, there’s a div tag with the id “content” that contains all the song rows as table row elements. I built a simple function that uses the LINQ Single method to find the tag by it’s id attribute value.

def FindById(node, id):
  def CheckId(n):
    a = n.Attribute('id')
    return a != None and a.Value == id
  
  return linq.Single(node.Descendants(), CheckId)

(Side note – I didn’t like the verbosity of the “a != None and a.Value == id” line of code, by XAttributes are not comparable by value. That is, I can’t write “node.Attribute(‘id’) == XAttribute(‘id’, id)”. And writing “node.Attribute(‘id’).Value == id” only works if every node has an id attribute. Not making XAttribute comparable by value seems like a strange design choice to me.)

LINQ to objects works just fine from IronPython, with a few caveats. First, IronPython doesn’t have extension methods, so you can’t chain calls together sequentially like you can in C#. So instead of collection.Where(…).Select(…), you have to write Select(Where(collection, …), …). Second, all the LINQ methods are generic, so you have to use the verbose list syntax (for example: Single[object] or Select[object,object]). Since Python doesn’t care about the generic types, I wrote a bunch of simple helper functions around the common LINQ methods that just use object as the generic type. Here are a few examples:

def Single(col, fun):
  return Enumerable.Single[object](col, Func[object, bool](fun))
  
def Where(col, fun):
  return Enumerable.Where[object](col, Func[object, bool](fun))
  
def Select(col, fun):
  return Enumerable.Select[object, object](col, Func[object, object](fun))

Once I have the content node, all the songs are in tr nodes beneath it. I wrote a function called ScrapeSong that transforms a song tr node into a Song object (which I’ll talk about in the next installment of this series). I use LINQ methods Select, OrderBy and ThenBy to provide me an enumeration of Song objects, ordered by date added (descending) than artist name.

def ScrapeSong(node):    
  tds = list(node.Elements(xhtml.ns+'td'))   
  anchor = list(tds[0].Elements(xhtml.ns+'a'))[0]   
     
  title = anchor.Value   
  url = anchor.Attribute('href').Value   
  artist = tds[1].Value   
  year = tds[2].Value   
  genre = tds[3].Value   
  difficulty = tds[4].Value   
  _type = tds[5].Value   
  added = DateTime.Parse(tds[6].Value)   
     
  return Song(title, artist, added, url, year, genre, difficulty, _type)   

songs = ThenBy(OrderByDesc(  
          Select(content.Elements(xhtml.ns +'tr'), ScrapeSong),   
          lambda s: s.added), lambda s: s.artist)

And that’s pretty much it. Next, I’ll iterate thru the list of songs and get the details I need from Zune’s catalog web services in order to write out a playlist that the Zune software will understand.

Posted By Harry Pierson at 5:16 PM Pacific Standard Time
IronPython | LINQ | Rock Band | XML | Zune

IronPython and Linq to XML Part 1: Introduction

Shortly after I joined the VS Languages team, we had a morale event that included a Rock Band tournament. I didn’t play that day in the tournament since I had never played before, but I was hooked just the same. I got Rock Band for my birthday, Rock Band 2 shortly after it came out in September and I’m hoping to get the AC/DC Track Pack for Christmas.

There are lots of songs available for Rock Band - 461 currently available between on-disc and downloadable tracks – with more added every week. Frankly, there’s lots of music on that list that I don’t recognize. Luckily, I’m also a Zune Pass subscriber, so I can go out and download all the Rock Band tracks and listen to them on my Zune. But who has time to manually search for 461 songs? Not me. So I wrote a little Python app to download the list of Rock Band songs and save it as a Zune playlist.

I ended up use Linq to XML very heavily in this project. Zune playlists use the same XML format as Windows playlists, Zune exposes the backend music catalog via a Atom feeds and I used Chris Lovett’s SgmlReader to expose the HTML list of Rock Band songs as XML. I realize Linq to XML wasn’t on “the list”, but I had a specific need so it got bumped to the head of the line.

BTW, for those who just want the playlist, I stuck it on my Skydrive. Unfortunately, there’s no Skydrive API right now, so I can’t automate uploading the new playlist every week. If anyone has alternative suggestions or a way to programmatically upload files to SkyDrive, let me know.

Posted By Harry Pierson at 5:07 PM Pacific Standard Time
IronPython | LINQ | Rock Band | XML | Zune

Thursday, April 24, 2008

Morning Coffee 164

  • Big news since my last Morning Coffee post was the announcement of Live Mesh. I've been running it for about a month, and I'm really digging it. Make sure you check out the team blog and watch the developer tour video (be on the lookout for IPy about half way thru the video)

ALT.NET

  • I had a great time @ the ALT.NET open space conference last weekend. I was somewhat distracted on Saturday as due to a family communication mixup, I had to bring my son Patrick with me. Jeffrey Palermo shot a cute video of him (3 minutes in) where he explains that he's at the conference "to be with my dad". Having a five year old is a little distracting, but everyone was amazingly cool with having him around. When he gets a little older I have no doubt he'll be attending conferences and leading open sessions.
  • I did a session on F#, but it felt kinda all over the place. I hadn't touched F# in a few months and it showed IMO. Matt Podwysocki was there to help keep the session from devolving into mass chaos. Thanks Matt.
  • My favorite session of the conference was Scott Hanselman's "Are We Innovating?" talk, which I think originated from a question I asked him: There are many examples of large OSS projects in other dev communities that get ported to .NET (NHibernate, NAnt, MonoRail, etc). Can you name one that's gone the other way? I can't.
  • I took Matt's advice and joined the local ALT.NET Seattle group.

DyLang Stuff

  • Martin Maly posts about how dynamic method dispatches are cached in three different layers by the DLR. You shouldn't care about this stuff if you're a DLR language user, but you will certainly care about it if you're a DLR language builder.
  • I'm really excited to see Phil Haack (whom I met F2F @ ALT.NET) is experimenting with IronRuby & ASP.NET MVC. True, I'd rather it was IPy, but his Routes.LoadFromRuby would work with Python with very little code change.
  • Note to self, take a deeper look at Twining, the IPy database DSL by David Seruyange.
  • Daily Michael Foord - Ironclad 0.2 Released. Ironclad is a project to implement Python's C extension API in C# so that IronPython could load standard Python C modules like SciPy and NumPy. So far, they're able to load the bz2 module

Other Stuff

  • Congrats to Brad and Jim for shipping xUnit.net 1.0.
  • Everyone seems to be jumping on the functional C# coding bandwagon. Bart De Smet's series on pattern matching in C# is currently at eight posts. Now Luca Bolognese is in on the action, with three posts so far on functional code in C#. I like how Luca keeps writing that the C# syntax is "not terrible" for functional programming. Again, why suffer thru the "not terrible" syntax when you could be using F# instead? (via Charlie Calvert)
  • I need to take a look at VLinq. Charlie and Scott Hanselman both mentioned it recently.
  • I would like to have been in the conversation with Ted Neward, Neal Ford, Venkat Subramaniam, Don Box and Amanda Silver.
  • I haven't had any time to play with XNA of late, which means the great list of GDC videos Dave Weller posted on the XNA team blog will remain beyond my ability to invest time for now.
  • There's a new drop of Spec# from MS Research. IronRuby is using Spec# heavily as I recall.
Posted By Harry Pierson at 10:53 AM Pacific Daylight Time

Tuesday, March 18, 2008

Lunchtime Coffee 158

  • My friend (and hopefully my next representative) Darcy Burner is leading a group of congressional challengers in publishing A Responsible Plan To End The War In Iraq. I haven't read the plan itself in detail, but I sure like what I'm hearing about it.
  • Speaking of politics, Obama's speech today "A More Perfect Union" was fantastic.
  • Bioshock is getting a sequel. 'nuff said.
  • There's a new version of FolderShare out and I've got mixed feelings about it. On the one hand, I've been a regular user of FolderShare for a while so it's nice to see it get a face lift. On the other hand, it's been over two years since Microsoft bought FolderShare and we're only just now getting a new version, which is literally nothing more that a face lift - this version introduces no new functionality at all.
  • I was hoping to geek out vicariously via someone else's hacking around with Singularity. Luckily, Matthew Podwysocki provides just such an opportunity.
  • Looks like "Prism" is the new CAB. Glenn Block has two extensive posts covering a project overview and their first drop. I think it's interesting that the Prism team is focused on building a reference implementation, and letting the framework eventually fall out. Reading thru the description, it sounds awesome. However, based on the massive increase of inbox throughput I'm experiencing since I accepted the new job, I can't imagine I'll have time to play with it. Maybe Matthew will start playing with Prism too! (via Sam Gentile - btw, thanks for the kind words on the new job Sam!)
  • Speaking of Sam, he points to a series by Bob Beauchemin entitled LINQ to SQL and Entity Framework: Panacea or evil incarnate? With a title like that, who can resist reading the whole series? Err, I can because LINQ 2 SQL & EF performance just fell off my radar entirely. However I gotta agree with Sam's point that he "can't think of anyone more qualified than Bob" to tackle these questions.
  • Tomas Restrepo blogs his dev environment PS script as well as a PS fortune script. Personally, I use Chris Tavares' vsvars wrapper for PS, though I'll gladly take an "official" PS based dev environment.
  • I wonder if Ted Neward will get jumped for admiring Mort the way Nick Malik did. Given that Ted called himself Mort while Nick compared Mort to agile developers, I'm guess Ted will have to go back to his Vietnam analogy if he wants to create controversy.
  • Speaking of Ted, I agree with his point that conferences are about people. As a python pre-newbie (I figure I'll reach full newbie status by the time I actually start my new job), I spent most of my PyCon time connecting with people rather than trying to learn technical stuff. Also, I love Ted's WHISCEY acronym.
  • Speaking of PyCon, my soon-to-be new teammate Srivatsn Narayanan blogs his thoughts on PyCon. I'll try and get to my PyCon thoughts soon.
Posted By Harry Pierson at 11:49 AM Pacific Standard Time

Monday, March 03, 2008

Morning Coffee 152

  • I was slammed Friday, so I didn't get a chance to post the results of last Thursday night's hockey game. I'm sure you've all been eager to hear. We lost, bad, 8-2. Personally, I was -3 and had no points, but I played much better than last week. We had three full lines of forwards, which was a big help, but I have started to find my ice-legs so to speak.
  • Charlie Calvert has the now-definitive list of LINQ to Everything. Of all of them, I found LINQ over C# fascinating, especially given my recent efforts in parsing.
  • Chris Tavares blogs about a distributed source control system called Bazaar. Unlike most version control systems, Bazaar is distributed which means you can use it without a server. According to Chris, you can share branches as easily as mailing a file. I wonder if you could make Bazaar work over a P2P network.
  • While looking up the MSDN link for the previous coffee item, I noticed an entire new section in the MSDN Library for Open Protocol Specifications. Not much to add, just wanted to highlight their existence.
  • Admitted non-designer Scott Guthrie shows off using the new version Expression Blend to build a Silverlight 2.0 app. Personally, I was most interested in seeing some of the new of built-in controls.
Posted By Harry Pierson at 10:58 AM Pacific Standard Time

Wednesday, February 27, 2008

Morning Coffee 150

  • Yesterday was the NHL trading deadline, and the Capitals were very busy. They obtained Huet from Montreal, Federov from Columbus and Cooke from Vancouver. Given they are fighting just to make the playoffs, going for three soon-to-be unrestricted free agents seems like an odd choice. However, the consensus (among my parents anyway) was that it's critical to get this very young Caps team some playoff experience. Even if all three walk at season's end, it'll be worth if the Caps make a playoff run. Besides it's not like we gave up much: an extra second round pick in '09, a 19 year old defensive prospect (who was apparently 14th on the depth chart) and an underachieving winger.
  • Speaking of the Caps playoff chances, they are currently one and a half games back of the division leading Hurricanes and two games behind the current eighth seed Flyers. Yes, I rank hockey teams using baseball's standings system. Otherwise, you have to talk about games in hand (i.e. the Caps are five points behind Carolina with two games in hand).
  • The writer's guild ratified the new contract, so Hollywood labor strife is now officially behind us. At least until July when the the actors may go on strike.
  • It seems like a slow week for Microsoft geek news, which is odd since WS08, VS08 and SQL08 all launch today. I'm guessing it's the calm before the Mix storm next week.
  • After going dark for six months, Linq to XSD has been re-released to work with the RTM version of VS08. Scott Hanselman demonstrates Linq to XSD by applying it to OFX, an XML Schema he calls "goofy" but apparently helped develop. OFX uses derivation by restriction, which has no direct corollary in C#, but Linq to XSD's  is able to translate between XML and objects without loosing any of that type fidelity. Nice to know Linq to XSD can tolerate OFX's level of goofiness, though I'm guessing most people use much more straightforward schemas.
  • Speaking of Linq, I discovered LINQPad via a comment on Rob Conery's blog (which I found via DNK). It's basically a code snippet IDE for C# 3.0 and VB9, with it also has built in database connection support, so it can fulfil much the same role as SQL Management Studio. I only played with it for a few minutes, but I was really impressed.  This is definitely going in my utilities folder. I wonder if they're interested in supporting F#?
  • Not sure how I missed this, but you can get MSDN Magazine via same Syndicated Client Experience as Architecture Journal. Unlike AJ which is divided into issues, the MSDN magazine client is divided into topics which is harder to square with the physical magazine. On the other hand, since MSDN Mag has been around longer, perhaps topics + search is a better discovery mechanism.
  • Soma announces the Visual Studio Gallery, a repository of VS Extensions. It's kinda cool, but the whole discovery mechanism is clunky. I might like to experiment with some free or even free trial products, but there's no way to filter on cost so finding them is a hassle. Also, there's no way for community members to vote, rate or comment on the products in any way.
  • Nick Malik can't answer the question "how does Enterprise Architecture demonstrate value?" I could be snarky and say "it doesn't", but that's only half the answer. It doesn't, but it should. My opinion, since you asked Nick, is that EA fails to deliver value because it tries to control the uncontrollable. Trying to gain efficiency thru establishing standards and eliminating overlap via reuse are pipe dreams, though literally millions of $$$ have been poured into those sink-holes. There are a few areas where centrally funded infrastructure projects can solve big problems that individual projects can't effectively tackle on their own. EA should focus their time there, they can actually make a difference. Otherwise, they should stay out of project's way.
Posted By Harry Pierson at 10:17 AM Pacific Standard Time

Wednesday, January 09, 2008

Morning Coffee 137

  • Note, I somehow duplicated Morning Coffee 135. So I've skipped 136 to make up for it.
  • Congrats to Hillary Clinton for her unexpected win in the New Hampshire primary. As I said last week, I think Obama has a better chance of winning in November, but I've got nothing against Clinton or her politics.
  • Speaking of winning, congrats to LSU on winning the BCS. Are they the best team in college football? Personally, I don't think so - there are at least three other teams (Georgia, West VA and of course USC) who can make a persuasive argument that they should be #1. But losing to teams like Penn Pitt and Stanford, neither WVA and USC have an argument they should have been in the championship game. But that's what makes the BCS such BS. If nothing else, at least the "we need a playoff" meme is picking up steam.
  • This is sort of cool: Eye-fi is a wireless enabled SD card so you can wirelessly upload pictures from your camera to your PC or favorite photo service. However, I think the price needs to come down a bit. I recently bought a 2GB SD card for my wife's new camera for $20. A 2GB Eye-fi card is $99. Not sure wireless upload is worth 5x per card.
  • With all the focus on LINQ providing type-safe queries, it's easy to forget that some apps do need to build their queries at run time. Scott Guthrie points at a Dynamic LINQ C# sample (also available for VB) that builds LINQ expression trees from strings. It kinda takes you back to the bad-old-days of embedding SQL strings in your code, but there are scenarios - especially BI scenarios - where you need this capability.
  • Soma announces the VC++ 2008 Feature Pack Beta. This is the long-awaited (by who?) MFC update as well as support for the C++ TR1. TR1 provides some FP-esque support like function objects and tuples, so maybe this is worth a look. On the other hand, given that much (all?) of TR1 is lifted from Boost, maybe we should just use that.
  • Speaking of cool libraries, check out C5 (aka the Copenhagen Comprehensive Collection Classes for C#). It's basically a complete redesign of System.Collections.Generic (or SCG as they call it). I've read thru their online book and I'm very impressed. Of course, with me focused on F# of late, I'm primarily using immutable collections, so I'm not sure how much use I have for C5 right now.
  • There was a free CoDe magazine in my DevTeach bag back in November with a fascinating article on where LINQ goes from here - LINQ 2.0 if you will. One of things the article discusses is tier-splitting, which has seen the light of day in Volta. Will Volta also deliver External Relationships, Reshaping Combinators and Join Patterns or will those come from different projects?
  • I had to pave my workstation yesterday. I was running an interim build of Vista x64 SP1 and I couldn't make Virtual Server work with it. As part of the repave, I discovered I needed to update the firmware of my SCSI controller, but the update had to run under DOS. Freaking DOS? My workstation doesn't even have a floppy drive to boot DOS from! However, I was able to boot from a USB thumb disk instead. That's damn useful.

Monday, August 27, 2007

Morning Coffee 115

  • Scott Guthrie has two new posts in his series on LINQ to SQL. The first covers updating the database using stored procs instead of dynamic SQL. I was somewhat surprised that there wasn't the capability to auto-generate vanilla Insert, Update and Deleted procs, but I guess DBA's probably hate that anyway. The second shows how to use ExecuteQuery to execute arbitrary SQL instead of using the cool LINQ query syntax. I'm doing a bunch of loosely-typed SQL work right now, so I'm going to take a deeper look at this.
  • Speaking of LINQ, I just discovered this great series on IQueriable by Bart De Smet. It's four months old, but takes an incredibly detailed look at what happens under the hood with LINQ. Bart also has a reference implementation of LINQ's standard query operators as well as LINQ to Sharepoint.
  • Dan Maharry has pulled together what looks like the definitive guide for really slimming down and speeding up your VPC. It's XP specific, but I'd bet most of the guidance would also apply to WS03, which is what I mostly use in my VPCs. (via Larkware)
  • Jimmy Nilsson thinks it's the operations department that holds the power in today's IT world. I agree 100% That's why I value Dale's input so much.
  • Nick Malik wonders if it's time to translate the Federal Enterprise Architecture for use in the commercial sector. My dad just retired from 5 years in the FAA and he thinks FEA is too high level to be particularly useful.
  • The 2007 edition version of Scott Hanselman's ultimate tool list is now available.
  • A bunch of XNA Gamefest sessions are now available for on-demand viewing.
Posted By Harry Pierson at 10:34 AM Pacific Daylight Time

Thursday, August 23, 2007

Morning Coffee 113

  • I'm in Chicago today and tomorrow for a reunion of sorts. In my last job, I managed a group of external architects called the Microsoft Architecture Advisory Board (aka the MAAB). We discontinued the program a while back, but the core of the group found the program valuable enough they have continued to meet anyway. I found the MAAB meetings incredibly valuable and insightful, so I'm really excited to be invited to continue my involvement with the group.
  • I picked up Bioshock Tuesday (Circuit City had it on sale) on my way to my bi-weekly campus excursion. My meetings were over around 2pm so I headed home early, expecting to surprise the kids. But Jules had decided to skip naps and go shopping with them. Her cell phone was dead, so I ended up at home with a couple of hours to myself and a brand new copy of Bioshock. Wow, is that a good game. Certainly deserving of the amazingly good reviews it's garnered.
  • Speaking of reviews, this transparently biased review of Bioshock over at Sony Defense Farce Force is frakking hilarious. Somehow, I doubt their dubious review will stem the tidal wave of Bioshock's well-deserved hype. Can't wait to read their Halo 3 review.
  • Pat Helland writes at length on master-master replication. I reformated it into PDF so I could read it - the large images were messing up the text flow on my system. As usual for Pat, there's gold in that thar post. His thoughts on DAGs of versions and vector clocks as identifiers are very exciting. However, I think he glosses over the importance of declarative merging. I would think programmatic merge would likely be non-deterministic across nodes. If so, wouldn't you end up with two documents with the same vector-clock identifier by different data?
  • Joe McKendrick points to a few people who predict the term "service-oriented" will eventually be subsumed under the general heading of "architecture". Not to brag, but I made that exact same prediction almost three years ago.
  • Erik Johnson thinks that SOA 2.0 centers on transformational patterns. The idea (I think) is that if systems "understand each other more deeply", then we can build a "smarter stack" and design apps via new constructs to promote agility and simplicity. Personally, I'm skeptical that we can define unambiguously system semantics except in the simplest scenarios, but Erik talks about using "graph transformation mathematics" to encode semantics. I don't know anything about graph transformation mathematics, but at least Erik has progressed beyond hand waving to describing the "what". Here's looking forward to the "how".
  • New dad Clemens Vasters somehow finds time to implement an XML-RPC binding for WCF 3.5. I was encouraged that it didn't require any custom attributes or extensions at the programmer level. Of course, XML-RPC fits semantically into WCF's interface based service model, so it shouldn't be a huge surprise that it didn't require any custom extensions. But did it need WCF 3.5? Would this work if recompiled against the 3.0 assemblies?
  • Phil Haack writes a long post on Duck Typing. VB9 originally supported duck typing - the feature was called Dynamic Interfaces - when it was first announced, but it was subsequently cut. I was really looking forward to that feature. Between it and XML Literals, VB9 was really stepping out of C#'s shadow. I guess it still is, even without dynamic interfaces.
  • Since I've been doing some LINQ to XML work lately, I decided to go back and re-write my code in VB9 using XML literals. While XML literals are nice, I don't think they're a must have. First, LINQ to XML has a nice fluent interface, so the literals don't give you that much cleaner code (though you do avoid writing XElement and XAttribute over and over.) Second, I find VB9's template syntax (like ASP <%= expression %>) clunky to work with, especially in nested templates. Finally, I like the namespace support of XNames better. As far as I can tell, VB9 defines namespaces with xmlns attributes just like XML does. So I'm not dying for literal XML support in a future version of C#. How about you?
Posted By Harry Pierson at 7:23 AM Pacific Daylight Time

Friday, August 17, 2007

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.

Posted By Harry Pierson at 4:55 PM Pacific Daylight Time
ADO.NET | Database | Development | LINQ | Ruby | XML

Thursday, August 16, 2007

Morning Coffee 111

  • I'm not sure if I should laugh or cry at Nick Malik's definition of politecture. I mean, it's funny so I'm laughing, but it's so true that it makes me want to cry.
  • Don Box comments on retiring the tenets. It's good to see him say "please God tell me we can do better" than CLR interfaces or WSDL.
  • Looks like the P2P APIs are finally getting the managed treatment in .NET FX 3.5. A long time ago, John deVadoss asked me what an enterprise system like CRM might look like if it used a peer-to-peer approach instead of client-server. If I had any free time, I'd prototype one out on this API. (via Mike Taulty)
  • Scott Guthrie goes back to his LINQ to SQL series to tackle Stored Procs and UDFs. Being able to use UDFs inline with LINQ queries is very cool. However, it seems to me that LINQ discourages the use of stored procs. As a developer, I'd rather write LINQ queries than stored procs, if I can. The probably puts me at odds with DBAs who'd rather all DB access be via stored procs they control.
  • Soma writes about new MSBuild enhancements in VS08: multi-targeting and parallel build.
  • I just discovered Vista Battery Saver. Basically, it turns off Aero and Sidebar when you're on battery. I'm traveling to Chicago next week, so we'll see if it has much impact on my battery life. (via Plenty of Code and Larkware)
Posted By Harry Pierson at 11:06 AM Pacific Daylight Time

Wednesday, August 08, 2007

Morning Coffee 109

  • I forgot to add a number to my last morning coffee post. However, after extensive research, I have determined that it was #108. So thing are continuing as usual today with #109. On the other hand, do you really want development and architecture opinions from a guy who can barely count? :)
  • The finalists in the Dream-Build-Play contest have been announced. I haven't played any of them yet (some are available for download) but they several of them sure look good.
  • And speaking of gaming, MS announced an Xbox 360 price drop yesterday. So if you want to get in on some of the XNA action, here's your chance (or you could just build for your PC - take your pick).
  • Finally on the gaming front, if you're not busy Monday you can watch the first day of Gamefest 2007 online. Get the scoop on XNA 2.0 as well as the new XNA networking support. I, alas, am busy Monday so I'll have to catch it on demand.
  • On to, you know, actual geek stuff things. Scott Guthrie seems to have retired his LINQ to SQL series and moved on to LINQ to XML. He shows how to build an RSS reader application with LINQ to XML. An oldie demo, but a goodie.
  • Wanna learn F#, there's a whole site of samples up on CodePlex. (via Don Syme)
  • Jeff Atwood is annoyed at how many different products you have to install to get a current & complete setup of VS 2005. Of course, MS shipped two parts of that stack since VS05 shipped (TFS & DBPro), three service packs (VS05 SP1, SQL 05 SP2 and DBPro SR1) and a major OS upgrade (VS Vista update). Doesn't the same thing happen with any shipping product after a few years? BTW, if this is such a huge hassle, I wonder why Jeff doesn't create a slipstreamed VS installer?
  • Udi Dahan has a great post on estimation where he claims "Developers don’t know how to estimate." No argument, but the way he phrases it sounds like it's the developer's fault they suck at estimation. It's not. Developing - by definition - is building something you've never built before. Is it any surprise we suck at estimating how long it will take us to do something we've never done before?
Posted By Harry Pierson at 10:15 AM Pacific Daylight Time

Thursday, August 02, 2007

Morning Coffee 107

  • The last day of the service factory workshop was much like the second, primarily focusing on stuff p&p built to integrate GAT and DSLs. We also got a briefing in what's coming for factories after VS08 (can't blog about that). We ended with a look at the DSL Editor Power Toy, which provides additional views on a given model and allows you to completely replace the graphical editor with a Windows Forms UserControl. I wonder if you could use ElementHost in order to build a WPF based editor?
  • Finished the last Harry Potter book last night. My wife finished it last week but kept quiet about it until I got to the end. No spoilers here, but I wasn't exactly surprised by how it played out. I wonder what J.K. Rowling will write next?
  • As promised, Silverlight 1.0 RC and Silverlight 1.1 Alpha Refresh were released last week. Also finishing out this beta wave were Silverlight 1.1 Alpha Tools for VS08 and a new preview of Expression Blend 2. Scott Hanselman has all the details on all the releases.
  • In one of his articles on LINQ to SQL, Scott Guthrie mentioned the LINQ to SQL debug visualizer in passing. Now, he drills into that feature in more detail. Apparently, this isn't a built-in feature of VS08 - it has to be installed separately. Make sure you do that, this seems like a must-have extension for LINQ to SQL development.
  • Jeff Atwood is worried that he spends more time talking about programming than actually programming. That's exactly why I left evangelism to join MSIT.
  • I'm still way behind on blogs, but if I don't post this soon, it's going to be an afternoon coffee. I've also got this day job thing that I've been away from for several days. So more old news tomorrow.
Posted By Harry Pierson at 11:25 AM Pacific Daylight Time

Friday, July 13, 2007

Morning Coffee 101

  • In doing a little LINQ research, I stumbled upon Wes Dyer's Yet Another Language Geek blog. Fascinating stuff. Subscribed. Be sure to check out his recent posts about Partial Methods, another new C# 3.0 (and VB9) language feature.
  • Werner Vogles has a great post on what a CTO does, including a summary of four different approaches to the job.
  • Somasegar lets us know that even though VS08 doesn't launch until February of next year, MSFT is "still aiming to release Visual Studio 2008 and .NET FX 3.5 by the end of this year".
  • There's a new version of the Windows Live Mobile Search client. The Virtual Earth / Live Search team blog has the details. New features include Movie Showtimes, More Local Data with Reviews and improved Maps and Directions (including GPS integration). Can't wait to get this installed. (via Dare Obasanjo)
  • XNA Gamefest is coming up next month. It's sort of like PDC for game developers. It's where we make our big game dev announcements - last year, we announced XNA GSE there. They recently published their session abstracts, including a whole track on XNA Game Studio Express. As Shawn Hargreaves points out, an "enterprising reader could probably make a good guess" about some of the new stuff getting announced @ Gamefest.
Posted By Harry Pierson at 11:38 AM Pacific Daylight Time

Thursday, May 31, 2007

Morning Coffee 86

  • Google announces Gears, a browser plugin for taking your web application offline. Developer docs are also available. TechMeme has lots more, but obviously this is yet another significant bow shot in the upcoming unified client platform war. By my count, there are four horses in this race: Microsoft with .NET and Silverlight, Adobe with Flash and Apollo, Google with AJAX and Gears and Sun with Java and JavaFX. Did I miss anyone? (via Dare Obasanjo and Scott Hanselman)
  • Alex James writes that REST is about intent and shows a pseudo-code sample posting multiple changes to a single endpoint as a way of demonstrating your intent that they be applied atomically. Andres Aguiar left a comment saying that Astoria does something similar. Personally, I like that model for transactions better than the transaction factory approach Jon Udell describes. But either way, you've moved beyond simple CRUD style services and into the world of protocol. Surfacing intent via protocol aligns with what Tim described as making the protocol explicit
  • Windows Live posted new beta versions of Writer, Mail and Messenger. I've been on an internal build of the new Writer for a while and I've really been impressed. There's also a new Provider Customization API, so I can't wait to see what the DasBlog folks do with that.
  • Scott Guthrie's LINQ series continues, this time covering how to build the LINQ to SQL data model. Looks like they used the DSL toolkit to build the LINQ to SQL data model designer, cool! 
  • Martin Fowler digs into racc, a yacc-esque compiler compiler for Ruby. Looks interesting as a internal DSL example (better than the now-canonical rake example). But why is the sexy new language on the block using old school CFG's instead of new hotness PEG's?
  • Speaking of Martin, he writes about the opportunity Ruby presents to Microsoft, building on Scott Hanselman's concerns that Microsoft is losing the Alpha Geeks. Sam Gentile also weighs in, suggesting that Microsoft is at the crossroads. Frankly, I don't work in evangelism anymore so I'm going pass these links along without comment except to say that Scott, Martin and Sam are all folks I have much much respect for.
Posted By Harry Pierson at 11:15 AM Pacific Daylight Time

Monday, May 21, 2007

Birthday Coffee 80

  • Saw Shrek the Third over the weekend with the kids. It's gotten mixed reviews, but I liked it even though it wasn't as good as the first two. Is it just me, or has sequel-itis reached an all time high? This month alone we've had Spiderman 328 Weeks Later, Shrek the Third and the new Pirates movie opens this week.
  • Hot on the heels of his post on anonymous types, Scott Guthrie starts to explain LINQ to SQL, which is where all these C#3/VB9 features have been headed. Lots of digital ink have been spilled on this topic since we announced LINQ @ PDC 05, so I'll just point out that I think this is the first OR/M solution that really works well across the board.
  • David Ing sucks the fun out of PopFly by suggesting it might be a "nice data aggregation / reformatting service for technically-challenged managers [and] their business data". Sounds like the next step of enterprise mashups.
  • Speaking of PopFly, Larry O'Brein thinks PopFly is helping restore " the bridge between power users and programmers". From the PopFly FAQ: "We’re going back to our roots in 1975 when Microsoft originally launched BASIC for the Altair 8080. Tools like BASIC and Visual Basic 1.0 democratized development by enabling users to easily build applications on DOS and Windows. We believe we can make Popfly a great tool for building and sharing applications on the Web."
  • Scott Hanselman wonders if Microsoft is losing the Alpha Geeks. In a related vein, I wonder if MS should be learning more aggressively from the community. MS has been the source of many developer innovations, but certainly not all. For ideas pioneered elsewhere, we tend to eventually get it, but I think we could be better about it.
  • Apparently, I'm just a little younger than video games. Pong was born May of 1967, only three years to the month before me. (via Ozymandias)
Posted By Harry Pierson at 1:07 PM Pacific Daylight Time

Monday, April 23, 2007

Morning Coffee 68

  • My wife and I celebrated our seven year anniversary over the weekend. She rocks. 'Nuff said.
  • Over the weekend, Gov.Gregoire signed a bill that protecting the rights of same-sex couples. It's not the same as full marriage rights (which long time readers know I fully support) but it's a step in the right direction.
  • I picked up the Xbox 360 HD DVD player over the weekend. Rented Batman Begins and it looks awesome. However, it wasn't the stunning difference between standard and high def TV programming. I wonder if my five year old HDTV is showing it's age.
  • Scott Guthrie continues his LINQ series with a post on the new Query Syntax in C#3/VB9. While this is feature is great for those who are using LINQ to SQL, it does force pretty much all LINQ to whatever providers to support the from-where-orderby-select pattern. But not all query sources want to be limited to that model. For example, if you wanted to do a LINQ to Data Warehouse, wouldn't you want more flexibility in your query syntax?
  • I didn't realize Steve Jones had a blog. At least, I think this Steve Jones is the Steve Jones that I know. But I'm not sure. Either way, it looks good so I subscribed... (via Sam Gentile)
Posted By Harry Pierson at 10:25 AM Pacific Daylight Time

Monday, April 09, 2007

Afternoon Coffee 59

Friday's Morning Coffee didn't happen because I fraked up the DNS settings when I moved devhawk.net to a new registrar. Today's morning coffee was drastically delayed on account of car troubles. Tuesday, I have an 8am meeting so tomorrow's not looking good either.

  • The big news for Xbox 360 is details on the Spring Update. Big news is WLMessenger integration + a QWERTY thumb pad that snaps right into the controller. (via Gamerscoreblog and Major Nelson)
  • Speaking of Xbox, I completed the Old Spice Experience Challenge today on my lunch break (couldn't go to the office due to the car troubles). My reward is an upgrade to level 2, a gamerpic I'll never use and a free copy of Contra. (Estimated total value: $5)
  • Scott Guthrie continues his series on new language features in C#3/VB9. This time it's lambda expressions. This is the "killer" feature in the new language version IMHO, since you can use lambda expressions either as code or data. Furthermore, it's up to the class/method handling the lambda expression to decide if it should be treated as code or data. That decision is made and design time, but the upside is that as a developer, I write my queries exactly the same way regardless if they are to be executed directly (aka code) or analyzed (aka data). Scott also metions a few new LINQ to * projects: LINQ to Amazon, LINQ to NHibernate and LINQ to LDAP.
  • Speaking of LINQ to *, here's LINQ to 3D Objects in a C# ray tracer. I think it's safe to say that LINQ to *whatever* is the new hotness. (via DotNetKicks)
  • The new version of F# is out. Looks like the big new feature is Active Patterns which is described in this draft paper. If I only had more time to investigate this. (via Don Syme)
  • For the third time in the past six months, my laptop power supply has died. I've never had a problem like this before, much less three times. It's not even the same laptop as I recently moved over to a Tecra M4 Tablet. I just don't get it.
  • P&P has shipped the 3.0 release of Enterprise Library. Tom Hollander has the details. Personally, I am most interested in the new Policy Injection Block.
  • Having worked with self-signed certificates and understanding what a PITA they are, it's nice to see that IIS 7 has explicit support for them.
  • I saw a reference to "The Halo Effect" on one of the political blogs I read. Needless to say, as an Xbox gamer, my first reaction was that this had something related to Master Chief. It doesn't.
  • Joe McKendrick compares SOA governance to national governance. Given our polarized political climate, this analogy may hurt more than it helps. Also, the next enterprise architectural board that has equal "branch" footing with IT and executive management will be the first.
Posted By Harry Pierson at 2:45 PM Pacific Daylight Time

Thursday, February 01, 2007

Morning Coffee 22

  • I figured out something to build with PowerShell. Not ready to spill all the beans yet, but I've started by building a provider for SQL Server. SQL already has the SQL Management Objects (SMO) library, so I can really focus on how PowerShell works rather than getting too bogged down in the logic of the provider. I'm sure someone else is working on something similar, but my primary goal with building this provider is to understand PowerShell. The codebase itself is a distant second in priority.
  • On the subject of missing LINQ's, Alex James wants LINQ to Web. A good potential use for the Windows Live Search API.
  • I posted three recent blog posts to DotNetKicks yesterday, but I've only collected one additional kick so far (for my Compiling Workflows post). Looking at what does gather kicks, I think I would need to write a more dev focused article if I wanted to make the DNK home page.
  • Don Smith left a comment on my WSSF post where he talked about the developer and the architect perspective. He seemed surprised that I took the developer perspective. To quote David White: "Architect Must Implement". The customization opportunity in guidance automation is huge, but the value is to the developer first. And while it's a good start, it doesn't go very far at automating the development experience. At heart, I guess I'm a developer even though my business card sez Architect (with a capital "A" these days no less).
  • I moved my laptop over to Vista yesterday. My workstation is still on XP, but that's because I haven't had time to completely rebuild my dev environment. No Aero support with the
  • I elbowed my way into the TS Gateway pilot at Microsoft and I'm loving it. TS Gateway is a new feature of Longhorn Server that "enables authorized remote users to connect to terminal servers and remote desktops on the corporate network from any Internet-connected device running Remote Desktop Connection 6.0." So I can quickly and easily remote into my desktop from anywhere without establishing a VPC session. The only annoyance is my USB smart card reader, which is fine in a pinch but a pain to constantly have dangling off my laptop. However, my boss approved a PCMCIA smart card reader so soon that won't be an issue.
Posted By Harry Pierson at 10:41 AM Pacific Standard Time

Wednesday, January 31, 2007

Morning Coffee 21

  • With this post, I will have posted 31 times in January. I doubt I will average a post a day for the rest of the year, but I've averaged less than half a post for a day for the past two years.
  • LINQ to whatever is the new hotness. The ADO.NET team blogged about LINQ to DataSet last week. Of course, there's also LINQ to SQL, LINQ to XML, LINQ to Entities and LINQ to XSD. Am I missing any other LINQ's? (Would that be the missing LINQ? har har har)
  • Joe McKendrick writes on "rogue" systems in the enterprise. In typical pundit fashion, he doesn't bother to take a stand on the subject, going so far in this case of having a reader poll rather than offering up his own opinion (wouldn't want to be wrong, would we?). However, I thought it was interesting that the three poll answers were "No rogue services", "Sometimes rogue services are OK" and "Why fight it?". Where's "Yes, let's directly empower the users" in that list?
  • I finally got around to installing PowerShell on both my laptop and workstation. I love the concept, but so far I just haven't had the time to dig into it or found a good problem to solve with it.
  • Windows Live now has it's own SDK. According to the Windows Live Dev News, the new and updated areas of the unified SDK include Search, Alerts and adCenter. (via DotNetKicks)
  • Speaking of DotNetKicks, is it just me or are a lot of the links submitted by their original authors? Steven Cohn on Service Layer Transparency, Keyvan Nayyeri on How to Write Validators for Custom WF Activities, Mads Kristensen on Universal Data Type Checker just to name three of the top four articles currently on the DNK home page. Seems fishy to blow your own horn like that, but since SNK shares advertising revenue with story submitters, it sorta makes sense.
Posted By Harry Pierson at 10:51 AM Pacific Standard Time

Thursday, April 06, 2006

LINQ + WAP == Coolness

I never really missed Web Application Project support in VS05 until I realized what I could do with it. I've been experimenting with LINQ and wanted to be able to use it in a web application I'm prototyping. Under the file system model, there's no easy way to change the compiler used for dynamic compilation of web pages. With WAP, it's no problem.

If you've got both WAP and LINQ installed, you can enable LINQ support in your web apps by doing the folllowing.

  1. Open your WebApp.csproj file in notepad.
  2. Add references to System.Query, System.Data.DLinq and System.Xml.XLinq.
  3. Change the Target Import element to import "$(ProgramFiles)\LINQ Preview\Misc\Linq.targets" instead of "$(MSBuildBinPath)\Microsoft.CSharp.targets"

That's it! Seems simple, but it let me bind a GridView to the following function:

public static IEnumerable<Titles> GetTitles()
{
 
var con = new SqlConnection(Properties.Settings.Default.PubsConString);
 
var db = new Pubs(con);
 
var q = from t in db.Titles select t;

  return q;
}

It would be even cooler if I could simply write that query in the conext of the ObjectDataSource, but of course ObjectDataSource doesn't know about LINQ. I imagine a LinqDataSource would be a logical next step.

Posted By Harry Pierson at 5:48 PM Pacific Daylight Time
Change Congress
Recent Bookmarks
Tags .NET Framework (2) __clrtype__ (9) ADO.NET (5) Agile (7) AJAX (3) Architecture (284) Guidance (6) Interop (2) Modelling (61) Patterns (7) Process (4) SOA (93) Web Services (5) ASP.NET (24) Azure (1) Battlestar Galactica (3) BI (2) BizTalk (4) Blogging (117) dasBlog (11) Podcasting (4) BPM (1) C# (11) C++ (4) Capitals (5) CardSpace (3) CLR (2) College Football (10) Comedy Central (1) Community (81) Concurrency (6) Consumer Electronics (1) Database (13) Debugger (18) Dependency Injection (2) Development (119) C Plus Plus (1) Embedded (5) Lanugages (40) Media (2) P2P (11) Rotor (1) SharePoint (6) SOP (3) DIY (1) DLR (19) Domain Specific Languages (15) Durable Messaging (5) Dynamic Languages (10) Dynamic Silverlight (1) Education (3) Enterprise 2.0 (1) Entertainment (14) ETech (15) F# (51) Functional Programming (17) Game Development (2) Guidance Automation (3) Hardware (8) HawkEye (3) Health (1) Hockey (31) Home Electronics (1) Home Network (5) Humor (5) IASA (1) Idempotence (3) infrastructure (5) Instrumentation (4) Integration (2) IronPython (92) IronRuby (13) Java (2) Job (3) Kodu (1) LangNET (2) LINQ (23) Live Framework (3) Live Mesh (2) Lost (1) Master Data Management (1) Media 2.0 (6) Microsoft (31) MIX06 (2) Mobile Phone (1) Monads (5) Morning Coffee (172) Object Oriented (4) Office (5) Open Source (7) Open Space (2) Operations (3) Other (135) Art (1) Books (1) Family (33) Games (18) General Geekery (26) Home Theater (1) Movies (23) Music (20) Politics (3) Society (1) Sports (37) Working at MSFT (17) Parallel Programming (3) Parsing Expression Grammar (16) patterns & practices (2) PDC08 (5) Politics (48) PowerPoint (2) PowerShell (37) Presentation (5) Projects (1) HawkWiki (1) Python (6) Quote of the Day (4) Refactoring (1) Research (2) REST (18) Reuse (5) Robotics (2) Rock Band (4) Rome (5) Ruby (23) Ruby on Rails (1) Sci-Fi (2) Scripting (4) Security (3) Service Broker (14) SharePoint (2) Silverlight (20) Social Software (1) Software + Services (2) Software Design (1) Software Factories (11) Software Industry (1) Spark (1) SQL Server (2) Stephen Colbert (1) TechEd (7) TechEd06 (1) TechRec League (1) Television (6) Travel (6) Unified Client (1) Unit Testing (4) USC (1) UX (1) Virtual PC (2) Visual Basic (2) Visual Studio (20) Volta (2) Washington Capitals (37) WCF (31) Web 2.0 (65) Web Services (5) WF (21) Windows (1) Windows Live (28) Windows Live Writer (2) WPF (7) Xbox (1) Xbox 360 (54) XML (11) XNA (15) Zune (4)
Disclaimer: The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Inappropriate comments will be deleted at the authors discretion.