Mike Taulty's Blog
Bits and Bytes from Microsoft UK

September 2007 - Mike Taulty's Blog

Blogs

Mike Taulty's Blog

Elsewhere

  • Grouping in LINQ is weird (IGrouping<K,T> is your friend)

    Ok, it's not weird really - I was just trying for an "attention grabbing headline" :-) However, it does seem to throw people when they play with it so I thought I'd break it down a little here. Say I've got some data such as; class Fruit { public string Name { get; set; } public string Type { get; set; } public decimal Price { get; set; } public int Quantity { get; set; } } Fruit[] data = new Fruit[] { new Fruit { Name= "Gala" , Type= "Apple" , Price=0.75m, Quantity=10 }, new Fruit { Name= "Granny Smith" , Type= "Apple" , Price=0.80m, Quantity=7 }, new Fruit { Name= "Tasty" , Type= "Strawberries" , Price=1.90m, Quantity=20 } }; and I want to group up by Type. This is easy enough to do; var grouped = from fruit in data group fruit by fruit.Type; but what the heck is grouped ? Well, it's (in my case) as GroupedEnumerable but that's not a public type so it doesn't help much. In many ways, it's much easier to figure out what's going on here when you look at this kind of query "long hand", for example; var grouped...
  • MSDN Silverlight Talk in Reading (25th September)

    Mike has published the demos and the slides that we used for our Silverlight talk in Reading on the 25th September.
  • Horace Goes Halo

    I think that the first video game that I bought was Hungry Horace As I remember, this was 1982 and I was 11 or 12 depending upon when I bought it. I can remember that part way through the game you could press BREAK and drop into the BASIC source code and then hack around with it which I thought was a fantastic way of playing around with things. 25 years on, I'm still pretty much doing the same thing (and still pressing BREAK but now it's in the debugger). Who'd have said that 25 years later this kind of messing around would have turned into this; with estimates that this might make more than $100m in a single day? I guess it's time that I went and bought one of those fancy, new-fangled Xbox 360 things? :-)
  • Herb Sutter's Machine Architecture Talk

    I've seen Herb Sutter talk a few times. I've read quite a few of his books (back in the day when I still wrote C++) and I used to religiously read the "Guru of the Week" although it's tailed off for me over time as I don't write much C++ these days. I spotted that he's put up a link to a talk on Machine Architectures . It's not often that I say this kind of thing but if you write code this is something that you should definitely watch. I'm looking forward to finding a couple of hours to watch it.
  • Expression Design, Blend and Effects

    Something I hadn't really thought much about before today - the possible loss of fidelity when you go from something like Expression Design to Expression Blend. I drew this little bit of UI in Expression Design; Now, there are some effects applied to that rounded rectangle - specifically a bevelled edge and an outer glow. If you just copy and paste the XAML from this from Expression Design to Blend though you'll see; which isn't quite the same thing (i.e. the glow and the bevelled edge have gone). Now, the people who wrote Design are smart enough to know that this is the case so when you come to do an Export to XAML there's an option to ask what you want to do with effects and it looks like the most realistic option is to rasterize your vectors at that point to images and then things look a lot more like they did in Design (albeit by losing a bit of your XAML). Note: I should say that this was exporting to Silverlight, I'm not sure if I'd see the same effect here if I was going to WPF as WPF has a bunch of effects...
    Filed under: ,
  • Silverlight - Simulating Streaming

    Just a (perhaps not very useful) thought that I had today. If you'd got (say) a video that is 60 minutes long and you wanted to break it down into short pieces then with Silverlight you could quite easily chop it up into pieces that are, say, 2 minutes for the intro piece and then 10 minutes each for the follow-on pieces. You produce a simple manifest file such as; <manifest> <part file="1.wmv"/> <part file="2.wmv"/> <.../> </manifest> Then use the Downloader to suck down part1, whilst it's playing you suck down part2 and so on and start playing it when part1 completes. Ideally, the viewer won't notice what you're doing and if they quit part way through you don't have to download the extra bits.
  • Waiting for Leopard

    First I got one of these (very handy for running); Then I got one of these (very pleased with it so far - like the 80GB. Note to Mr Jobs - if you'd put 40GB in the Touch, I'd have got one but 16GB isn't enough); And now I'm waiting to get one of these; I'm waiting because I'm waiting for Leopard to ship. Frankly, I think Apple's missing a trick here because I'm sure a lot of people are doing the same thing and they could have the revenue now if they'd just promise to upgrade me to Leopard for free when it ships but I guess they know what they're doing. As an aside, I'm not buying a Mac because I want "another machine". I have a lot of machines running Windows so there'd be no point. I'm buying it purely so that I can try out a Mac. I have a long heritage in the Unix world (going back 20 years now) and I'd like to see how far it's come in MacOS X form. I'd also quite like just to have a "different" OS kicking around the house so that I can compare how things are done on either system. Now, here's the interesting...
  • UK MSDN Event Locations

    One of the things that we've really tried to do this year in terms of our MSDN Events Programme is to get to more locations than we've done in previous years and to try and do that on a regular schedule. This is something that I feel relatively strongly about as I don't live in the South East of the country myself so I appreciate that we've not always been as accessible to people as we might have been. Now, even with this year's efforts, we're still not going to be perfect but I do genuinely think we're doing a lot better than we've done in previous years and the only way that it'll get better still is if we see the demand from people for us to turn up either more frequently or in more (or different) locations. I've tried to use the Live Local map on the left to highlight where we're doing MSDN Events this year - essentially at the time of writing it's; Reading London Edinburgh Manchester Bradford (in association with Black Marble ) Bristol Birmingham This will almost certainly change as the year goes on and we...
  • Disconnected LINQ to Entities

    Taking this post here and changing from LINQ to SQL and LINQ to Entities. What would that involve? Firstly, I add a new ADO.NET Entity Data Model to my project (call it Northwind.edmx). I add only my Customers table and I leave the default mapping alone. ( I renamed the entity to Customer not Customers otherwise there's too many plurals ). Then I returned to the two scenarios that I had in the LINQ to SQL post. 1) Where We Do Not Store The Original Values Here's the service code that I wrote for this; [ServiceContract] class Service { [OperationContract] public Customer GetCustomer( string customerId) { Customer c = null ; using (NorthwindEntities entities = new NorthwindEntities()) { c = entities.Customers.Where(cust => cust.CustomerID == customerId).First(); } return (c); } [OperationContract] public void InsertCustomer(Customer c) { using (NorthwindEntities entities = new NorthwindEntities()) { entities.AddObject( "Customers" , c); entities.SaveChanges( true ); } } [OperationContract] public void DeleteCustomer...
  • VB XML Tool

    The IntelliSense from Schema stuff when working with XML in VB is really quite cool and now there's a new tool to help with that . Another thing to add to my downloads list.
  • VB9 Dynamic Identifiers, Dynamic Interfaces, Partial Methods

    Via Daniel I learnt that VB9 changed in Beta 2 of Visual Studio and that dynamic identifiers and interfaces have gone and that Partial Methods are now in. Must admit that I found it hard to verify this on the web without quite a bit of searching. The VB Team Blog is perhaps the best place for this sort of stuff.
  • RIA Job Trends & Salaries

    Found this interesting . I wonder if I could get myself some kind of Silverlight, WPF, C# job then? :-)
  • Blend 2 September Preview

    If you're playing with Silverlight then you'll no doubt be using Blend 2 and you might have spotted that it's recently been saying "Your trial is about to expire". Frankly, I was getting a bit panicky but it looks like there's a new drop of Blend just come out. More here - from the title page it looks like it now supports VS2008, turning an existing bit of content into a control, split view for the XAML editor, new one of interacting with Storyboard and lots of other bits and pieces. Installing now....there's some more info here - I enjoyed my first play with the Easing on an animation.
  • Typing

    Daniel wants me to try this . It said that I do 90 words/minute. Having said that, it didn't work perfectly for me in that the scrolling up the screen was a bit dodgy - I had to hit the scrollbar at one point and then it started scrolling just slightly too quickly so that I got into a bit of a panic trying to chase the text as it disappeared up the screen. I've a feeling that I'd find it easier if the words were coming "from my head" or possibly being read to me rather than typing one piece of text below another piece of text. So...when this software job goes wrong (like it didn't already :-)) I can perhaps hope to get a job as a typist (or do you need to hit 120wpm for that?).
  • Disconnected LINQ to SQL

    It's a common scenario to build an application with multiple physical or logical tiers and a very common example would be where we have something like; If we imagine that our "web service" just does CRUD on some entity type (say Customer) then we've got a situation where. Initially we have a Customer row in the DB - call it C1. Web Service queries for it. Web Service returns it. Client gets a copy of it. Call it CC1. Client modifies it to produce C2. Client returns C2 to web service. Now, at step 6 we have a few options; Client returns C2 and only C2. In the middle tier, we have kept no state so we don't know whether there are changes between C1 and C2 and so the best we can hope for is to update all the columns in the DB. Additionally, we don't know whether the row in the DB has been modified since the client read it so we can't check for concurrency violations. Client returns C2 and only C2. In the middle tier, we have kept a copy of C1 and so we can perform a comparison and only update the columns in the DB...
1 2 Next >