2 years later.

Well after well over 2, nearly 3 years I’ve revived the blog.

A whole lot has changed in that time, it’s kinda crazy…


Firstly I left my very first developer job, much to my sadness. I came across a new position with Betfred which would allow me to develop my career in the direction I wanted it to go, in that I would be joining a company that was undergoing an Agile transformation. Working as part of a team in an Agile environment was something i was really missing before, but now i’m reaping the benefits. The amount of knowledge and experience I’ve gained so far from this position is unquantifiable. I feel like I’ve undergone a complete transformation, and am now capable of writing software to a standard I didn’t think I was capable of. (I need to stop underestimating myself!).

As much as it was hard to leave my previous position due to the rapport I had developed with colleagues and the managing director himself, I believe it was absolutely the right thing to do and the perfect time to do it. Being the only developer at the company, I didn’t want to leave them in a position of difficultly. Luckily I mentioned the open position to my brother, who was keen to become a developer after being a hobbyist since a young age, he has successfully taken on my previous role and is making amazing progress as a Junior Developer. I can see him become very successful in the industry.



Pretty self explanatory, yet nonetheless exciting times. As of November 2016 me and my partner became homeowners. Searching didn’t really take all that long. We knew that we wanted to stay within the Winstanley Area of Wigan, where we had previously been renting a property together, so that narrowed the search down dramatically. After viewing several houses in the area, we stumbled across this one. We fell in love with it straight away. The room sizes were perfect, very generously sized garden and the added bonus of being backed on to by woodland. Now don’t get me wrong, there is lots of work that needs to be done to modernize, but i’m embracing that as part of the fun and experience! After all, I made a career out of wanting to be creative.



Also, last but by absolutely no means least, I became a father for the first time! Baby Jacob John made his way in to the world on the 23rd February at 16:47 – (Just in time for dinner!). Becoming a father has been one of the most amazing experiences I could have ever imagined, and this is only just the beginning. Coming home from work and seeing his face light up when he see’s me is one of the most amazing feelings in the world. You can have had a very stressful day where nothing has gone to plan, but coming home to that just makes every ounce of worry and stress disappear in an instant. He’s developing an amazing little personality – such a happy baby and I couldn’t be more proud.


On-wards and upwards…

So after a rather incredible and life changing 2 years, and feeling very accomplished – I’m left wondering what’s next? Well I aim to keep on doing what I love – Developing software, learning new things each and every day and who knows where it may take me. But whatever challenges lay ahead – Bring ’em on!

Generating C# Classes from SQL Tables

I’ve recently started a new project that is very database heavy, and I couldn’t help but find myself writing what can only be described as a ridiculous amount of boilerplate code to model entities. You might say, erm, Dan? Use an ORM? Entity Framework will take care of it for you… Now before I get into the details of this post, I want to state that this is not a post comparing Entity Framework to ADO.NET. I simply prefer to use ADO.NET and keep the flexibility that comes with it.

So, using ADO.NET, how can I generate C# Classes using my preexisting SQL Tables? Well, I found this utter GEM of an answer to this very question on our beloved StackOverFlow. (Check out the question here). We can use the following Query in SQL Server to return a C# class structure for our table:

declare @TableName sysname = '<TABLENAME>'
declare @Result varchar(max) = 'public class ' + @TableName + '

select @Result = @Result + '
    public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }
        replace(col.name, ' ', '_') ColumnName,
        column_id ColumnId,
        case typ.name
            when 'bigint' then 'long'
            when 'binary' then 'byte[]'
            when 'bit' then 'bool'
            when 'char' then 'string'
            when 'date' then 'DateTime'
            when 'datetime' then 'DateTime'
            when 'datetime2' then 'DateTime'
            when 'datetimeoffset' then 'DateTimeOffset'
            when 'decimal' then 'decimal'
            when 'float' then 'float'
            when 'image' then 'byte[]'
            when 'int' then 'int'
            when 'money' then 'decimal'
            when 'nchar' then 'char'
            when 'ntext' then 'string'
            when 'numeric' then 'decimal'
            when 'nvarchar' then 'string'
            when 'real' then 'double'
            when 'smalldatetime' then 'DateTime'
            when 'smallint' then 'short'
            when 'smallmoney' then 'decimal'
            when 'text' then 'string'
            when 'time' then 'TimeSpan'
            when 'timestamp' then 'DateTime'
            when 'tinyint' then 'byte'
            when 'uniqueidentifier' then 'Guid'
            when 'varbinary' then 'byte[]'
            when 'varchar' then 'string'
            else 'UNKNOWN_' + typ.name
        end ColumnType,
            when col.is_nullable = 1 and typ.name in ('bit', 'date', 'datetime', 'datetime2', 'datetimeoffset', 'decimal', 'float', 'money', 'numeric', 'real', 'smalldatetime', 'smallint', 'smallmoney', 'time', 'tinyint', 'uniqueidentifier')
            then '?'
            else ''
        end NullableSign
    from sys.columns col
        join sys.types typ on
            col.system_type_id = typ.system_type_id AND col.user_type_id = typ.user_type_id
    where object_id = object_id(@TableName)
) t
order by ColumnId

set @Result = @Result  + '

print @Result

Lets give it a try…

I’m going to test this code using a fairly basic table as an example. This table is called “OrderItems”, and is responsible for holding data about items relating to a customers order. Consider a table that has the following fields:

ID    int
OrderItemID    nvarchar(50)
SKU    nvarchar(50)
Quantity    int
ItemPrice    money
ShippingPrice    money
OrderID    int
ClientID    int

Pretty simple! So lets run the query against this table, and we get the following output:

public class OrderItems
    public int ID { get; set; }

    public string OrderItemID { get; set; }

    public string SKU { get; set; }

    public int Quantity { get; set; }

    public decimal ItemPrice { get; set; }

    public decimal ShippingPrice { get; set; }

    public int OrderID { get; set; }

    public int ClientID { get; set; }


Just what we wanted!

Don’t forgot to change the <TABLENAME> with the name of your table, eg:

declare @TableName sysname = 'OrderItems'


I hope that by sharing this, it will help as many of you as possible – in the same way that it has helped me.

Credit: Alex Aza on StackOverFlow.com.

Microsoft Open-Sources the .NET Framework

Microsoft .NET Logo


Developers Rejoice!

Microsoft announce that they’re making .NET open source and cross platform. News broke on wednesday via an msdn blog post from S. Somasegar, the corporate vice president of the Developer division at Microsoft.

Somasegar goes on to summarise the key points of the announcement:

  • Over the coming months, we will be open sourcing the full server-side .NET Core stack, from ASP.NET 5 down to the Core Runtime and Framework, and the open source .NET will be expanded to run on Linux and Mac OS X in addition to Windows.
  • Visual Studio Community 2013 is a new, free and fully featured edition of Visual Studio, available today, with access to the full Visual Studio extensibility ecosystem and support for targeting any platform, from devices and desktop to web and cloud services.
  • A preview of the next generation of our tools is available today with Visual Studio 2015 Preview and .NET 2015 Preview.  Together, these bring industry-leading cross-platform mobile development tools, deep support for cloud development, and great productivity improvements across the breadth of the developer experience.
  • Visual Studio 2013 Update 4 is available now for every Visual Studio 2013 user, including dozens of improvements across the product plus several great new features.
  • Visual Studio Online is expanding its DevOps portfolio with the new Visual Studio Online Release Management service and Visual Studio Cloud Deployment Projects.

Microsoft have also created a new hub for their open source projects on github: http://microsoft.github.io/

On the whole, the news was very well received within the developer community. And rightly so. Good move Microsoft.

Some Twitter reaction:

  (My personal favorite)






SQL Server – Return a list of parameters from a Stored Procedure

In SQL Server, you can query the database to return the parameters that a Stored Procedure contains. This can be achieved like so:

    p.name AS Parameter,
    t.name AS [Type]
FROM <DATABASE NAME>.sys.procedures sp
JOIN <DATABASE NAME>.sys.parameters p
    ON sp.object_id = p.object_id
JOIN sys.types t
    ON p.system_type_id = t.system_type_id
    sp.name = '<STORED PROCEDURE NAME>' AND t.name != 'sysname' 

You can change the SELECT to a COUNT(*) if you just want the number of parameters.


Credit: JodyThttp://stackoverflow.com/a/15431637/1914145