XAML formatting using Visual Studio 2013

If you, like me, are obsessive about the appearence of your xaml code and spent time to line up properties just the right way, you will be delighted to know that Visual Studio has a number of formatting tricks up its sleave to help you with this task. One of these features is the ability to break a long XAML Element declaration into multiple lines with each element property automatically placed on a new line. To enable this, you have to do the following: In Visual Studio, go to Tools -> Options -> Text Editor -> XAML …[read more]


Backing up SQL Server to Azure Storage account using T-SQL

One of the cool things of SQL Server 2012, is the ability to backup any database to Azure. This frees DBA’s from having to maintain tapes for offsite backups. Think of it as your Disaster Recovery on the cheap (and easy) The setup is incredibly simple and I would urge you to take advantage of this feature as soon as possible. If you don’t have an Azure account, you can get one here In order to be able to backup to Azure, you need to configure a credential to store the Windows Azure Storage authentication details. You can …[read more]


Importing CSV files using jQuery and HTML5

One of the cool features of HTML5 is the new File API that allows the broswer to directly interact with files on the file system. Most modern browsers that support HTML5 can use this API to perform client-side only processing without the need for a round trip to the servers or the use of ajax etc. In effect the server becomes redundant and the user experience more fluent and responsive. You can still, if you need to, perform server-side processing, but if you only want to make the file contents available to the browser then you can use the code …[read more]


Getting Json data using jQuery and .ASMX web services.

If you still have the misfortune to work with asmx services on your project, you may want to know how to easily retrieve json data from an asmx method. The differences between asmx and WCF have been aalyze[d b]efore here and here. Return a simple string as json response:### Your asmx page code#### [WebService(Namespace = "http://contoso.com/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]System.Web.Services.WebService [ScriptService] public class services :WebService { [WebMethod(CacheDuration = 60)] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string GetGreeting() { return "hello world" } } Your javascript code#### …. code omitted … var getGreeting = function() { var …[read more]


Ordering Collections with enum properties using LINQ

Posted in Linq, c#

Interesting find today. To order a collection based on an enum alphabetically, you can use LINQ as per the example below: var collection = new List<myCustomObjectWithEnumProperty>(); var sortedCollection = collection.OrderBy(c=>c.EnumProperty.ToString()); To order a collection based on an enum by value, you can do the following: var collection = new List<myCustomObjectWithEnumProperty>(); var sortedCollection = collection.OrderBy(c=>(int)c.EnumProperty); Simple as that! Happy coding... …[read more]


TFS Continuous Integration for Windows 8.1 Store Apps with SDK dependencies

I am in the process of developing a Windows Store App which has a dependency on SQLite. Today, I decided to implement continuous integration (CI) using my hosted TFS service. If you are serious about CI but don’t want to host your own CI Server and go through the pain of setting up the CI provider (TeamCity, TFS, CruiseControl etc), I highly recommend you looking at the official hosted Team Foundation Service here. Although adding the custom build is very straightforward, I stumbled upon a few issues. The first problem was the fact that the project had a reference …[read more]


SQL Server Always On Availability Groups – Issue with preferred replica for log backups

Over the last couple of days I’ve been trying to customize Ola Hallegren’s script in order to perform backups on an Always On Availability Group running on Azure (blog to follow soon)[1]. I managed to get everything working apart from the Log Backups and the culprit was fairly easy to find. In Ola’s DatabaseBackup stored proc, there is a section of code that checks whether the specified backup type (full, diff, log) can run on the current server as per below: IF @Version >= 11 AND @Cluster IS NOT NULL BEGIN SELECT @CurrentAvailabilityGroup = availability_groups.name, …[read more]


Copying VHDs between private storage accounts

If you ever need to copy VHDs between two different storage account, you can use the PowerShell script below to do it in few steps: Perform the copy Firstly select the subscription you need to work with. Select-AzureSubscription "MySubscriptionName" Define the source VHD - authenticated container. You can get the vhd name and url from the portal $srcUri = "https://mysubscription.blob.core.windows.net/vhds/yourvhdname.vhd" Define the source Storage Account. This is where the vhd is currently located. The Private key can be acquired from the azure portal $srcStorageAccount = "sourceStorageAccount" $srcStorageKey = " …[read more]