 |
|
 |
|
|
Author: |
David Hanson |
Created: |
Wed, 02 Jan 2008 20:28:49 GMT |
 |
|
All things .net, wpf, XAML, C#, Workflow Foundation and many more. |
|
SQL Server: How to page query results |
|
|
By David Hanson on
Thu, 31 Jul 2008 17:20:11 GMT
|
|
|
|
The application I am working on at the moment has a large number of complex search screens that allow the user to define either very narrow or very broad query's. A great deal of effort has been spent in optimising the queries in order to ensure they are performant. However, if a user decided to execute a very broad query, the result set that could be returned could be many thousands of records. Let’s take a look at a broad query using this simple SQL.
Select ID, Forename, Surname
FROM Person Where Surname like '%DA%'
In this query we want to return everything from our person table where the surname contains the letter “DA”. Running this query gives us the following 99 results. I’ve randomized the data in our person data for privacy reasons.

Now this query is running on some test data but on a live system it might return 20,000+ records. Transferring this data from our DB server to our application tier, then into business entities and serialising them via soap to our client is going to be demanding process. This is not going to be a particulary great idea, a better approach would be to return results in pages so that we can maintain a responsive UI and reduced long running network calls.
Taking this example further, we lets say that we would like our page sizes to be 5 records each. The first page will return record 1-5 and when the user clicks next we require records 6-10 to be displayed. In order for us to be able to achieve this functionality we need to implement an index on our result set so that we can locate a particular page of data within the full results. To do this SQL server provides a handy function called which ROW_NUMBER()provides an incremental index for each record in our result set. If we implement the ROW_NUMBER()as part of our results we can see the results below.
SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 1)) as [Index], ID, Forename, Surname
FROM Person Where Surname like '%DA%'

We can now see from executed query above that our results contain and INDEX column which uniquely identifies each row returned from our results. By adding this index to our results we now have a way of navigating batches of records within our results set. To do this is not as simple as just adding a WHERE to our SQL statement, instead we must execute the full que ...
|
 |
|
Comments (0)
|
More...
|
|
|
Silverlight 2: Control Templating & The Visual State Manager - PART 2 |
|
|
By David Hanson on
Mon, 28 Jul 2008 09:02:56 GMT
|
|
|
In my previous post we took a quick look at some of the support blend offers for skinning controls in Silverlight 2. Within only a few minutes we were able to take an existing textbox control and extend its visual tree using a custom template. In this post I plan to take our previous skinned control example further by implementing some simple animations. This is a good chance to check out the new VisualStateManager which greatly simplifies the development of animations in Silverlight.
For the basis of this tutorial we are going to extend our textbox template so that when a users places their mouse over the textbox the control will grow to make the text more readable. When the mouse leaves the textbox control the text will shrink again back to its normal “State”. It’s the word “State” here that really matters.
If you are observant and you haven’t moved all your panels around in blend, you may have noticed a new panel called states on the left hand side of your IDE. The states panel is a visual interface for managing the different states your control can be in. To help make this clearer, we can take a look at the control template for a button control (See previous post for how to do this in blend).

As you can see the standard Silverlight button control has a number of visual states that it can placed into. If we click on one of these states in the designer, our design surface will reflect what the look control will be in that state. As an example below, if we click on the disabled state we can see that the button looks greyed out.

What is important about the VisualStateManager is that it allows us to focus in a design centric way what each state looks like when the state is changed. In order to manage states more effectively you can see that Blend provides State Groups in which we can hold multiple visual states. We are not concerned with how we get to a particular state, we are just focused on the final look once we reach it. Some of the magic behind the VisualStateManager will be covered later.
So if we move back to our previous textbox example, we specified that we want the control to increase its size when a mouse rolls over the control and when the mouse leaves, the control should return to its original size. Given this, we know that our control can be in 1 of 2 states. Using blend, we are going to create a new state group and add two states to our control. Shown below.

|
|
Comments (0)
|
More...
|
|
|
Silverlight 2: Control Templating & The Visual State Manager - PART 1 |
|
|
By David Hanson on
Thu, 24 Jul 2008 21:48:24 GMT
|
|
|
|
In this blog I wanted to provide a simple overview of some of the features provided as part of the June 2.5 Blend preview and Silverlight 2 Beta 2. Two of the key features that have been made available as part of this release is the ability to easily template controls in order to create your own custom skins as well as the new Visual State Manager which helps aid int the development of animations.
So lets get started. The first thing we want to do is have a look at how easy it is to create custom templates for controls using the June preview of Blend. We are going to create a simple Silverlight Application using the default project template provided by Blend. (Shown below)

Once Blend has created our project we need to create some very simple XAML. As this example is going to be VERY simple all we need to do is drag a textbox onto our design surface. Below shows the XAML of our form once this has been done.
<UserControl
x:Class="VSMDemo.Page"
Width="640" Height="480">
<Grid x:Name="LayoutRoot" Background="White" >
<TextBox Height="23&qu ...
|
 |
|
Comments (5)
|
More...
|
|
|
RIA's and Search Engines 2. |
|
|
By David Hanson on
Wed, 02 Jul 2008 15:35:17 GMT
|
|
|
|

A while back I blogged about the the trend in web content being developed using Rich Internet Application technolgies such as Flash & Silverlight. Previous Blog
Well an interesting announcement comes from Adobe which looks to address some of these issue going forward. Snippet below. Full article on business week here. Story.
"Flash, software, Adobe, Google, Yahoo, search engine, Web, Macromedia, photos, animationIf you're trawling the Web to buy a pair of Nikes, shop for a Volkswagen, or get a glimpse of Walt Disney's Wall-E, chances are you'll end up viewing graphics built with Adobe Systems' Flash software. Good luck finding them with a search engine, though. Turns out Google and other Web-search tools can't easily recognize pages laden with Flash-created images.
At least not yet. Adobe (ADBE) announced steps to solve those problems on July 1, providing Google (GOOG) and Yahoo! (YHOO) with software that will make pages inside Flash-powered sites show up higher in search results and infuse those results with more relevant details. Adobe's moves could persuade more consumers to visit its customers' sites and make Flash software more attractive to Web site developers. Adobe's agreements with the two biggest search engines on the Web is also a competitive slap at Microsoft (MSFT), which makes Web software that competes with Adobe's."
|
 |
|
Comments (0)
|
|
|
|
Free Download Manager |
|
|
By David Hanson on
Sat, 21 Jun 2008 11:35:45 GMT
|
|
|
|
Over the last few weeks I have been using the following product found here (http://www.freedownloadmanager.org/features.htm) which provides some cool features for downloading. Since using it I am starting to get the most of out of my 20mbps cable connection. The reason is due to the fact that the when downloading, the software creates multiple HTTP connections to the file. Check this download speed for the Silverlight 2 Beta 2 tools. Awesome.

Great speed for downloads
Key features
- Multiple HTTP connections for a single download (Make downloading ALOT faster)
- Automatically resumes on broken connections
- Torrent support
- Media Previews for partially downloaded files
- Download only certain files held in a zip file.
- Download entire sites

Screen shot
|
 |
|
Comments (0)
|
|
|
|
Cross-Platform DRM Support for Silverlight 2 Beta 2 |
|
|
By David Hanson on
Sun, 08 Jun 2008 16:32:14 GMT
|
|
|
|

I was having a read through of the feature set for Silverlight 2 Beta 2. One of the items that instantly stood out for me was the fact that with Beta 2 Support for DRM (Digital Rights Management) has made it, and more importantly...........IT’S CROSS BROWSER AND CROSS PLATFORM! Now let me be clear on this, I am not a fan of DRM as I believe as a consumer I have the right to use the content I have paid for in anyway I choose. I’m not suggesting copying and passing on too friends is fairplay but I do feel I should be able to duplicate the media for all the devices in my home. That said, although I am not a fan of DRM personally, I can greet this news with optimism and here is why.
About 18 months ago I was working on a contract for Siemens who were developing the packaging and delivery of the BBC IPlayers content. This was interesting work and really opened my eyes to the amount of effort that must go into launching a platform like the IPlayer. 18 months ago none of us working on the project had any idea as to how successful the IPlayer would be, therefore the application was built with performance and scalability in mind. A good thing too given the way it panned out.
While working on the project, one area I felt was seriously lacking was the cross platform support. All content delivered via the VOD system is encrypted using Windows DRM. As the name suggest, the result that decision was that all content inevitably becomes locked into the windows platform. Therefore unless you’re on a windows platform, the IPlayer would be useless to you.
The BBC were not the only ones to adopt this approach, SKY, ITV and Channel 4 have all built their VOD platforms on the Kontiki P2P system using Windows DRM. So as a guy with a Mac (Yes I run windows vista on it) I could consider myself up shits creek! So the question is, why is this good news? It’s good news as whether we like it or not DRM is essential for large media conglomerate when it comes to delivering their content over the web. Whether we like it or not, I still cannot see them dropping it due to public demand. Therefore, with Silverlight providing the tools necessasary for cross-platform DRM, adaptable streaming and the ability to generate amazing RIA’s there are very little hurdles left to overcome.
I expect to see the BBC move this way as they have previously confirmed that Mac support was on their todo list. Also some of the demo’s from MIX07 with the BBC Radio 1 site delivered via Silverlight show the potential. I am hoping to have a play with the new Silverlight 2 Beta 2 features in the next few weeks so expect some posts then.
|
 |
|
Comments (0)
|
|
|
|
Isle of Wight Festival and my technology addiction! |
|
|
By David Hanson on
Sat, 07 Jun 2008 17:37:29 GMT
|
|
|
|

I'm off to the Isle of Wight festival this week and as usual I have spent the weekend getting all the essentials together. I've got my tent dusted down, wellies, wet wipes beer and much more ready to go. However I am starting to think that I am a little to addicted. Here is a rundown of the gadgets i'm taking.
- IPod Touch
- ITrip
- Stereo to transmit music from IPod too.
- Solar Charger
- Camera
- Mobile Phone
- Walkie Talkes
- Windup torch
- Smartphone
Something tells me I may need to lock my tent up!
|
 |
|
Comments (0)
|
|
|
|
The power of Silverlight vectors |
|
|
By David Hanson on
Fri, 23 May 2008 10:58:53 GMT
|
|
|
|
As you probably know the power of WPF and its subset Silverlight is its ability to render images using vector graphics. I am not a graphic designer myself, I can usually get a decent design together but it’s usually more evolutionary rather than revolutionary.
As all images in vector graphics are expressed using mathematics they provide computers with some superior processing capabilities that are not possible with common binary formats. We can transform them, scale them, animate them to name just a few . However, with the advantages of having an image represented in mathematics, we also suffer with increased complexity when trying to create them from scratch.
With the current release of Silverlight, we have the power in the framework to represent near photo realistic images purely in vectors. Take for example the photo of me shown below, this image, running in Silverlight, has been built using only vectors. You can see this running in Silverlight here.

Bad Mood 
If we take a closer look at the structure of the eye, we can see that the complexity of the XAML path objects, which are the basic building blocks used to compose the image, are far beyond the capabilities of any human designer using tools such as Blend or Visual Studio.

The image was actually constructed using the cool site vectormagic.com. On this site you can upload any photo and it will convert the image to vectors. This covered off the majority of the grunt work of converting the image into vectors. VectorMagic offer you two free downloads in a range of formats.... but no XAML option. Therefore, I downloaded the file in Adobe Illustrator format, from there it was a simple process of exporting the image into XAML using Mike Swanson’s awesome AI-XAML converter.
Hope this quick example has helped illustrate the power of Silverlight’s graphical capabilities and gets you thinking about what other assets you could convert into XAML.
|
 |
|
Comments (0)
|
|
|
|
.NET 3.5 SP1 & Visual Studio 2008 SP1 Beta released |
|
|
By David Hanson on
Tue, 13 May 2008 08:31:57 GMT
|
|
|

It seems .Net 3.5 SP1 and Visual Studio 2008 SP1 beta are now available from Microsoft for download. This release brings a number of fixes for hundreds of bugs that have been reported by customers.
This download installs Visual Studio 2008 SP1 Beta. Visual Studio 2008 SP1 includes support for SQL Server 2008, new ADO.NET features such as the Entity Framework, improvements to the WPF designers, WCF templates for Silverlight projects, debugger support for the .NET Framework public symbols and source release, control improvements such as the DataRepeater for Windows Forms and Office 2007 Ribbons for C++, and several general updates for debugging and IntelliSense. SP1 also enhances the stability, performance, and security of many features.
The included .NET Framework 3.5 Service Pack 1 adds many new features and fixes, including the following:
.NET Framework Client Release (“Arrowhead”)
· ASP.NET Dynamic Data
· ASP.NET Routing
· ADO.NET Data Services
· ADO.NET Entity Framework
I’m just hoping that it resolves the constant OutOfMemory exceptions I get when working with the WPF designer. You can find the downloads here.
|
 |
|
Comments (0)
|
|
|
|
Oldest running code? |
|
|
By David Hanson on
Mon, 12 May 2008 09:08:03 GMT
|
|
|

Slashdot poses an interesting question asking what is the oldest code still running today. Of the 600+ comments so far I have cherry picked a few that I thought were good choices.
· The software on the Voyager and Pioneer SpaceCraft 1977
· Digital watches
· Heavy machinery used from the late 50’s
· Worryingly – Air Traffic controls system code from the 60’s
· DNA – At least 2 billion years old! J
But my personal favourite!
1 "Let there be light"
2 create universe()
3 while (1)
|
 |
|
Comments (0)
|
|
|
|
Cosmic Crashes |
|
|
By David Hanson on
Tue, 29 Apr 2008 19:51:56 GMT
|
|
|

I was catching up on some podcasts during my drive to work recently and came across an interesting topic on the BBC's Digital Planet podcast. The discussion was regarding the “impact” cosmic rays can have on our desktop computers and more importantly very expensive grid platforms such as IBM’s Blue Gene. Computer crashes can be annoyng to the average user but on grid platforms running simulations that require accurate data they can be very costly. During the podcast they had interviewed with an Intel researcher (who's name I have forgotten sorry) who was discussing his strategies for counter acting the effects these highly energetic particles can have.
Before I outline his proposal it’s probably worth explaining some rudimentary physics.
What is a cosmic ray?
Answer: A cosmic ray is a particle with mass greater than zero that has been been accelerated to a speed that is approaching the speed of light.
How does it get that fast?
Answer: A range of cosmic events can cause this but let’s just say for this blog, a star exploded millions of years ago and that it is this explosion that caused the cosmic ray.
I heard that most cosmic rays just pass right through us.. How come?
Answer: Well thanks to Mr Einstein we know that with increased mass comes an exponential increase in energy in order to accelerate the matter towards light speed. Therefore cosmic rays are generally low is mass. As a result, they can pass through the atoms in your body undisturbed. (Well mostly)
So how do cosmic rays cause computer crashes?
Answer: Computers processors are based on logic gates which manage the flow of electrons on the processor. When a cosmic ray hits the processor a surge or peak of energy is releases in the form of electrons which can result in the processor providing inaccurate results. (Hence it crashes).
So with the details out of the way I can get on to explaining what the Intel researcher was planning to in order to resolve this problem. Basically, his view on cosmic crashes was that it’s going to be almost impossible to stop them from happening, insulating the processor with cosmic ray impenetrable materials is going to be very hard, very large and expensive. So, instead he proposed that what we should do is build detectors which can identify the surge of electrons associated with a cosmic ray and then instruct the processor to rerun the previous calculation that may have been affected.
I must say... I like his thinking.
|
 |
|
Comments (0)
|
|
|
|
LINQ to Reflection Part 3: Updating Fields |
|
|
By David Hanson on
Mon, 28 Apr 2008 13:30:07 GMT
|
|
|
In part 2 of this LINQ 2 Reflection series I took you through how we go about querying fields that may existing within an object graph. Before we proceed, it’s important to remember that a call to object.Field<T> will return an instance of type Linq.Reflection.Field. As part 2 focused purely the reading fields it’s about time we take a look at how we can go about updating them. If we look at the intellisense that Visual Studio provides for the Field<T> class we can see that this class has an Update<T> method. Shown below.
Firstly, as the Update<T> method is contextual, there is no requirement to pass the name of the field we wish to update as this can be inferred from its parent. Secondly, As the Field<T> returns a generic class of type T it also allows us to infer the Type of value we wish to update. Below is a simple update statement on a person entity.
person
.Field<string>("_firstName").Update("James")
.Field<string>("_lastName").Update("Brown")
.Field<DateTime>("_dateOfBirth").Update(DOB);
The Update<T> method of the Field<T> class returns an instance of the parent object we are currently working with. Internally the Field<T> class passes the parent context down our chained methods. Therefore we have the ability to move up the object graph if so desired. In this situation, where we are updating 1 of many fields on the parent context, its important that the return value from Update<T> is that of the parent object.
As that’s pretty much it for updating fields using LINQ to Reflection. You can call the Update<T> on and Field<T> or Property<T> accessor. As this point in our series you have the information you need to drill down any object reading and writing property/field values to suit your tests scenarios.
In part 4 we will start looking at how we can leverage the power of these extensions methods by showing how we can mock internal objects without breaking the rules of encapsulation.
|
 |
|
Comments (0)
|
|
|
|
LINQ to Reflection Part 2: Reading Fields |
|
|
By David Hanson on
Fri, 25 Apr 2008 11:34:23 GMT
|
|
|
In part 1 of my LINQ to Reflection series I outlined some of the key drivers behind me creating a set of extension methods that can be used to query any CLR type. I also outlined that I am looking to extend this further with support for reading/writing of data, mocking, invocation, interception and other useful behaviours. This post is purely focused on the reading of field data using the LINQ to Reflection extension methods.
Before we get into the details of how we query data, we first need to create some tests data that will be used for each sample. Below is a method that is used to build object graph that is comprised simple and complex types with multiple child objects. Note: We are already starting to use our LINQ to Reflection methods in order to create tests data.
///<summary>
/// Sets up an object graph for our different test scenarios.
///</summary>
public static Person GetTestData()
{
Person person = new Person();
return FillPerson(person,3, 4);
}
///<summary>
/// Fills the person with test data.
///</summary>
///<param name="person">The person.</param>
///<param name="levelsDeep">
|
 |
|
Comments (1)
|
More...
|
|
|
WPF: Could not create an instance of type '{0}' |
|
|
By David Hanson on
Fri, 25 Apr 2008 09:10:57 GMT
|
|
|
|
If you get this error in your designer when working with XAML in Visual Studio 2008...make sure you dont have any visual elements that inherit from an abstract class. May seem obvious but can be easily missed. 
Could not create an instance of type '{0}'
|
 |
|
Comments (6)
|
|
|
|
The rise and fall of social networks |
|
|
By David Hanson on
Wed, 23 Apr 2008 19:47:05 GMT
|
|
|
|
It seems every six months a new social network is on the scene. If I was to guess who currently reigns supreme I would imagine facebook is likely to be in there. Google trends provides us with some insights into this question.

facebook, myspace & bebo
I will run this graph in a year and see how its changed. Until then make your own minds up.
|
 |
|
Comments (0)
|
|
|
|
|
|
|
|
|
|
|
 |
|
 |
|
Twitter / LordHanson
Published Sun, 04 Jul 2010 22:07:55 +0000
by
Published Sun, 04 Jul 2010 22:05:28 +0000
by
Published Fri, 25 Jun 2010 23:01:45 +0000
by
Published Fri, 25 Jun 2010 22:54:54 +0000
by
Published Mon, 14 Jun 2010 05:08:43 +0000
by
Published Mon, 14 Jun 2010 00:04:45 +0000
by
Published Sun, 25 Apr 2010 04:39:48 +0000
by
Published Wed, 10 Mar 2010 10:29:19 +0000
by
Published Mon, 22 Feb 2010 12:31:09 +0000
by
Published Thu, 18 Feb 2010 08:13:10 +0000
by
Published Tue, 26 Jan 2010 17:48:49 +0000
by
Published Fri, 22 Jan 2010 08:14:36 +0000
by
Published Tue, 19 Jan 2010 17:35:43 +0000
by
Published Sun, 17 Jan 2010 19:01:29 +0000
by
Published Sat, 16 Jan 2010 16:38:58 +0000
by
Published Sat, 16 Jan 2010 16:34:00 +0000
by
Published Fri, 15 Jan 2010 18:55:38 +0000
by
Published Fri, 15 Jan 2010 08:28:47 +0000
by
Published Tue, 12 Jan 2010 15:28:29 +0000
by
Published Sun, 10 Jan 2010 21:49:44 +0000
by
|
|
|
|
|
|
|
|
|
 |
|
 |
|
Silverlight - Google News
Published Thu, 29 Jul 2010 23:21:01 GMT+00:00
by
Published Tue, 06 Jul 2010 18:54:39 GMT+00:00
by
Published Mon, 26 Jul 2010 20:32:23 GMT+00:00
by
Published Fri, 30 Jul 2010 13:13:57 GMT+00:00
by
Published Fri, 30 Jul 2010 14:19:22 GMT+00:00
by
Published Fri, 30 Jul 2010 08:50:54 GMT+00:00
by
Published Thu, 29 Jul 2010 09:36:57 GMT+00:00
by
Published Mon, 26 Jul 2010 11:56:30 GMT+00:00
by
Published Tue, 27 Jul 2010 20:28:37 GMT+00:00
by
Published Tue, 27 Jul 2010 12:39:37 GMT+00:00
by
|
|
|
|
|
|
|
|
|