Mike Taulty's Blog
Bits and Bytes from Microsoft UK

Browse by Tags

Blogs

Mike Taulty's Blog

Elsewhere

  • 13th May – Session at the SQL Servers User’s Group at Microsoft, Reading

    Just a quick plug – tomorrow evening I’m doing a session on ADO.NET Data Services (“Astoria”) at the SQL Server User’s Group at Microsoft, Reading. See here for details; http://sqlserverfaq.com/events/167/Sessions-on-Understanding-ADONET-Data-Services-Windows-7-features-indepth-and-the-usual-SQL-Nuggets-and-Networking.aspx it’d be great to see you there.
  • Astoria Online/Offline

    Tantalising post from the Astoria team.
  • LINQ Talk at UK Visual Studio 2008 Launch

    I did a talk yesterday down at the UK Launch of Visual Studio 2008, SQL Server 2008 and Windows Server 2008 about Language Integrated Query as it stands in VS 2008 and .NET Framework V3.5. Firstly, thanks to everyone who came along to the talk - much appreciated. Also a massive thanks to the guys who helped us out with the track at the launch namely; Guy , Andy and Amanda who did a stunning job. An equally massive thanks to the guys who helped us out in the community area, the ATE and the labs who were all doing a great job - I won't list names here but you know who you are and what a big difference you made to the event :-) If you want to catch up on the launch after the event then you can check out the new ( Silverlight based ) Virtual Launch Experience which is up here; Virtual Launch Experience Now...the content isn't 100% the same as what we did in Birmingham so I thought I'd share my session with you here in written form in case you wanted some snippet from it. Firstly, here's the slides in PPTX , PPT and...
    Filed under: , ,
  • LINQ to XSD is Back :-)

    A new version of the LINQ to XSD preview that works with Visual Studio 2008. Get the details from here . If you're not so sure on what LINQ to XSD is all about it's essentially for the people who see some LINQ to XML code and say; "But how come the LINQ to XML code has all those ugly strings and casts in it? Can't that be worked out if I have a schema?" That's kind of what LINQ to XSD does for you. Now, if you're a VB programmer then it's a slightly different story as you don't get faced directly with all those ugly casts anyway in LINQ to XML and the tooling also has some clever XSD tricks up its sleeve for VB.
    Filed under: , ,
  • Reparenting nodes in LINQ to XML

    Someone mailed me the other day with a query as to how they can use LINQ to XML in order to change this XML file; <? xml version ="1.0" encoding ="utf-8" ? > < root > < x > < a /> < b /> </ x > < c /> < d /> </ root > into this XML file; <? xml version ="1.0" encoding ="utf-8" ? > < root > < a /> < b /> < c /> < d /> </ root > that is - find the node called "x" and remove it whilst reparenting its child nodes to the parent of the node "x". I ended up with something like; XElement doc = XElement.Load( "data.xml" ); XElement xEl = doc.Element( "x" ); doc.AddFirst(xEl.Descendants()); xEl.Remove(); which is fine (enough) but there's a part of me that would have liked to be able to collapse this down into less code. I managed to get it down to; XElement doc = XElement.Load( "data.xml" ); XElement xEl = doc.Element( "x" ); xEl.ReplaceWith(xEl.Descendants()); which felt a bit better and I can't really think of a way to cut...
    Filed under: ,
  • LINQ to XML and IXPathNavigable

    Something I've been pondering. Living over in System.Xml.XPath is an extension method to XNode (from LINQ to XML) called CreateNavigator . So, given something like an XElement ; XElement x = new XElement( "foo" ); I can go ahead and get an XPathNavigator from it; XElement x = new XElement( "foo" ); XPathNavigator nav = x.CreateNavigator(); So, how come we do this with an extension method rather than have XNode implement the existing IXPathNavigable ? I found that a bit odd and would be interested to know if someone has an explanation. It's not particularly hard to write a ToNavigable() extension with perhaps something like this (scribbled very quickly); public static class Ext { private class Navigable : IXPathNavigable { private XNode node; public Navigable(XNode n) { node = n; } public XPathNavigator CreateNavigator() { return (node.CreateNavigator()); } } public static IXPathNavigable ToNavigable( this XNode n) { return ( new Navigable(n)); } } and writing that had me thinking about how it would have been ...
    Filed under: , ,
  • LINQ to XML and Larger Files

    LINQ to XML and the XML API that underpins it contained in the System.Xml.Linq namespace is essentially a DOM-like API. This means that documents are loaded into memory to form a "tree" representation and that act of loading into memory means that the bigger the document you have, the more memory you're going to need. That's not always practical and the existing XML classes in the .NET Framework V2.0 have dealt with this by providing DOM-like functionality (i.e. XmlDocument, XPathDocument and so on) and streaming functionality via XmlReader and XmlWriter. The essential idea of an XmlReader is that it provides forward only, read-only cursor over an XML document. LINQ to XML does not have a general purpose way of working with large documents (read the discussion here and here ) but it does propose a pattern for doing it based on using an XmlReader. I created a relatively large XML file from selecting data from Northwind using a FOR XML query and then I used a quick PowerShell loop to concat the file onto itself...
    Filed under: , ,