Mike Taulty's Blog
Bits and Bytes from Microsoft UK

October 2007 - Mike Taulty's Blog

Blogs

Mike Taulty's Blog

Elsewhere

  • Developer Day (DDD) Number 6 Registration Site Open. 24th November, Reading.

    Registration is here , Agenda is here , main site is here . See you there.
  • SQL 2008 - Table Valued Parameters

    Hmmmmmmm. If I had a pound for every time someone has asked me in the past "What's the best way to pass an array of values into a SQL Server stored procedure" then I'd have at least 4 pounds :-) I've seen people do it with strings. I've seen people do it with XML (both before and after SQL Server actually had an XML data type). And now, with SQL Server 2008 we have table valued parameters. I created a table type; create type dbo.peopleTable as table ( firstName nvarchar(100), lastName nvarchar(100) ) I created a table; create table people ( id int identity primary key , firstName nvarchar(100) not null , lastName nvarchar(100) not null ) I created a simple stored procedure; create procedure dbo.InsertPeople ( @ data dbo.peopleTable readonly ) as set nocount on insert dbo.people select * from @ data go I called it from ADO.NET on the client side; private void InitializeData() { table = new DataTable(); table.Columns.Add( "firstName" , typeof ( string )); table.Columns.Add( "lastName" , typeof ( string )); dataGridView1...
    Filed under: , ,
  • A Message from our Sponsor - TechEd Europe

    Just a quick plug. I'm doing a couple of sessions at TechEd Europe which begins week commencing 5th November in Barcelona. TLA309 LINQ to XML: Using the Language Integrated Query (LINQ) Framework with XML Data XML developers have had to learn a combination of APIs and query languages in order to work effectively with XML. In this talk we will introduce Language Integrated Query (LINQ) to XML, a component of the LINQ project designed to improve XML data programmability from C# and Visual Basic. LINQ to XML allows developers to load, query, transform, and update XML data using modern, easy to use programming features, and don’t require knowledge of related technologies such as DOM, XPath, XSLT, and the details of namespace binding. This presentation will present the high points of the LINQ to XML API, show how it extends the LINQ query operators to work with XML data, and work through realistic examples that show how processing XML data can be less painful, and almost fun. (C) Wed Nov 7 09:00 - 10:15 Room 112 TLA326...
  • More on Filestream in SQL 2008

    I wrote a little demo around FILESTREAM in SQL 2008 so I thought I'd share - the code's a little shabby but I got to the point where it did what I wanted and so I stopped. Some days I miss not writing production code because it's very different from demo code and the differences are where I used to enjoy spending my time. Anyway, regardless...you need this SQL script to set up the single table involved here (or at least something a bit like it); use master go -- Switching the thing on in the first place. EXEC sp_filestream_configure @enable_level = 3; -- Need a filegroup that supports it too. USE master; GO IF EXISTS ( SELECT * FROM sys.databases WHERE name = N 'PhotoDB' ) DROP DATABASE PhotoDB GO CREATE DATABASE PhotoDB ON PRIMARY ( NAME = PhotoDB_data, FILENAME = N 'D:\data\PhotoDb.mdf' , SIZE = 10MB, MAXSIZE = 50MB, FILEGROWTH = 15%), FILEGROUP PhotoDBFS CONTAINS FILESTREAM ( NAME = PhotoDB_FS, FILENAME = N 'D:\data\Photos' ) LOG ON ( NAME = 'PhotoDB_log' , FILENAME = N 'D:\data\PhotoDB_log.ldf' , SIZE = 5MB...
  • The Lock Cookbook

    Joe Duffy has a fantasic post over on his site with a bunch of rules around using locks in .NET (and about concurrency generally). Really liked this stuff - particularly keen on "don't call other people's code when you're holding a lock" and "don't call blocking code whilst holding a lock" but there's a lot more golden info in that article and it's nice to see it all written down in one place.
  • SQL 2008, FILESTREAM, C++, Managed Code

    I spent a bunch of time today just trying to play with the FILESTREAM option on varbinary(max ) in SQL Server 2008. There's a good intro to doing this up here but it stops short of writing code against it which is where I wanted to go. So, I've created my database with a FILESTREAM filegroup, I've got a table with a FILESTREAM entry in it a la; create table Photos ( rowid uniqueidentifier rowguidcol not null primary key default (NEWID()), photo varbinary( max ) filestream ) and I've read about how I'm supposed to use PathName() as a function and then use GET_FILESTREAM_TRANSACTION_CONTEXT() as a function and then feed all that into a new API (in the SQL native client library) called OpenSqlFilestream but I look in the docs and I see that the declaration in the docs; HANDLE OpenSqlFilestream ( LPCWSTR FilestreamPath, SQL_FILESTREAM_DESIRED_ACCESS DesiredAccess, ULONG OpenOptions, LPBYTE FilestreamTransactionContext, ULONG FilestreamTransactionContextLength ); doesn't match the definition in the header file which...
  • LINQ to Entities - Customising the edmgen.exe Output

    I've had this post kicking around in my inbox for a while but hadn't got round to consuming it. It talks about how the EdmGen.exe process is a wrapper for classes that exist in System.Data.Entity.Design and you can take those classes and build them into your own code and use that to customise the generation process. Very cool - in an ideal world, all command line tools would be written like this so that you could add "that extra bit" of behaviour that you find yourself wanting but a tool not offering. I built a little bit of code around this that provides a kick-start in that it can take a config file such as; < configuration > < configSections > < section name ="generation" type ="WfEdmGen.exe.ConfigSectionHandler, WfEdmGen.exe" allowLocation ="true" allowDefinition ="Everywhere" /> </ configSections > < generation Language ="GenerateCSharpCode" > < propertyAttributes > < add name ="hideDebugger" type ="System.Diagnostics.DebuggerHiddenAttribute" /> </ propertyAttributes...
  • VBUG Conference

    Just back from the VBUG Conference where I saw a whole bunch of people incuding Dave , Oliver , Andrew , Tony , Alex , Guy , Rob , Barry and a lot more. I enjoyed it and delivered an old-favourite in the shape of a "Introduction to Workflow" session and something a little more topical in a "What's new in WCF and WF V3.5" session. For the attendees (and anyone else) the slides I used and the demo code that I used are all contained the zip file below; http://mtaulty.com/downloads/vbug08.zip The only caveat is that I built this code for me to demo things rather than for it to be easily re-used and understood so if you struggle with getting things working then I can't really help you with it I'm afraid. ( Of course - it's also subject to the general disclaimer at the bottom of the page which applies to any content taken from this site ).
  • LINQ to SQL: Beta 2 to RTM Changes

    Dinesh has a list of changes here . If you're using LINQ to SQL then this will have an impact on you. I'm not sure that I've 100% digested this aspect at this point so I'll need to revisit it. Actually, whilst you're there you probably also want to read; LINQ to SQL- What is NOT in RTM (V1) LINQ to SQL - features not in the designer/SqlMetal Ah, what the heck, you may as well just sign up to Dinesh's blog if you didn't already. No, wait a minute, don't do that as it looks like Dinesh is moving on from LINQ to SQL, subscribe to Tim instead :-)
  • Anonymous Types & Read-Only Properties

    I hadn't noticed this before; static void Main( string [] args) { var v = new { Prop1 = "A" , Prop2 = "B" }; v.Prop1 = "Foo" ; } Here's the error;
    Filed under: ,
  • ASP.NET and MVC

    Found this post on the forthcoming MVC implementation in ASP.NET to be interesting. Currently watching the video.
  • Interesting animation

    I found this site interesting. It's not so much for the content (which is fine) but it's more for the animation that occurs when you mouse over one of the people. Not sure how that's done but I quite like it. Unfortunately, it's done with Flash rather than Silverlight so I can't just download the source and have a look :-)
  • Weird Microsoft-Speak

    I've noticed a peculiar trend around Microsoft lately. We seem to be inventing our own language. I was having a laugh about this with David last night where we had examples such as; "TALKING TO"... When did it become ok for people to say "Can you TALK TO Windows Server 2008" whereas what they actually mean is "Can you TALK ABOUT Windows Server 2008". "THE WHOLE PIECE"... What is this thing with "the piece"? I'm constantly hearing this phrase of "We need to look at this across THE PIECE" or "THE WHOLE PIECE". Piece of what, exactly? "IS THAT AN OK ASK?" What's this thing with the word "ASK"? People have started saying "Is travelling to the Moon too much of an ASK for you?". What's that about? What happened to poor, old "REQUEST?" I have an idea that someone, somewhere is coming up with this weird way of abusing words and slowly slipping them into their dialogue as a way of seeing which other people they can trick into adopting them. I've a feeling that it might be Martin - I asked him what he'd been up to recently...
  • "REST", ASP.NET, WCF, Astoria

    Is anyone out there building a "RESTful" (quoted as this is a very overloaded term) framework for ASP.NET ? On the "RESTful" front, there's the bits that WCF V3.5 does for you but that brings in an awful lot of framework. Then there's the work that Astoria is doing but that also brings in a whole lot of framework (i.e. all of Entity Framework underpinning your work). So...nothing wrong with either of those where they make sense but I've a feeling that it'd be cool to have a nice little lightweight extension that plugged into ASP.NET and offered me URI and VERB based dispatch into my code. Does it exist? One note - maybe saying "ASP.NET" is wrong there because one of the things about ASP.NET is that (AFAIK) it wants me to be referencing an actual, physical file which I don't think is that helpful in this space. For example, I might want a URI such as; http://mybookshop.com/books/authors/enid%20blyton (GET) whereas (I think) ASP.NET would force me to do something like; http://mybookshop.com/books.ashx/authors/enid...
  • DurableServices in WCF V3.5 :-(

    I wrote about this once before . Let's say I'm building a service that I want to be stateless but has some notion of a session with a client. Let's say (for argument's sake) that the interface looks like this; public interface IServe { int GetFirstNumber(out Guid sessionToken); int GetNextNumber(Guid sessionToken, out bool isLastNumber); } Ok, so it's a messy interface but it serves the purpose of illustration. The idea is that the first time the client calls the service, the service will not only generate them their first result but it'll also return them a session id of some sort so that they can come back later on and resume the session in order to get the next number in the sequence. Naturally, you could hide the session id in a SOAP header or you could hide it in a transport (i.e. HTTP) header if you wanted to hide it from the interface (it's a good question as to whether you do IMHO). Now - in between calls to this service the implementation is going to serialize the state for the client. That is, it's going...
1 2 Next >