I’ve just been working through some Entity FrameWork tutorials and ended up with an error whilst trying to use .Include() (Eager loading instead of lazy loading)

Cannot convert lambda expression to type ‘string’ because it is not a delegate type

This is because the overload on System.Data.Entity.DbSet expect a string – Which is the name of the entity to eager load. I was passing in a lambda expression. I could of course just passed in a string, but this does not give me any compile time safety if my model ever changes.

The solution is to add a using statement:

using System.Data.Entity;

System.Data.Entity.Include() accepts a lambda expression, so my original attempt: …Include(a => a.County) compiles and works.




using System.Data.Entity;


I have had a few occasions where I’ve needed to run JavaScript on a page at first load only, or the oppposite – on a post back only. This can be achieved as follows:

<script type="text/javascript" language="javascript">

	function pageLoad(sender, args)
	    alert('Runs on every page load');

		if (args.get_isPartialLoad())
			alert('Runs on partial post back only');
        } else {
            alert('Runs on initial load only');

The other way is to conditionally use ClientScriptManager.RegisterClientScriptBlock(), using Page.IsPostBack to determine if this is the first load or a postback. Note that if you are using UpdatePanels (AJAX) on your page, you need to use ScriptManager.RegisterClientScriptBlock() instead, as ClientScriptManager.RegisterClientScriptBlock() will not survive a partial postback.

Its probably fair to say that most developers wont encouter a situation requiring a count as 21,474,83647 (Maximum capacity of .Net FrameWork System.Int32).

That said, its probably also fair to say that all developers should be aware of something called ‘Integral Overflow’, which is a behavour of System.Int32, meaning adding to the maximum value, or subtracting from the minimum value, results in an overflow/underflow.

This is demonstrated in the following code:

Int32 intMinVal = Int32.MinValue;
Int32 intMaxVal = Int32.MaxValue;

Debug.WriteLine(intMinVal); // -2147483648
Debug.WriteLine(--intMinVal); // 2147483648 - Underflow

Debug.WriteLine(intMaxVal); // 2147483647
Debug.WriteLine(++intMaxVal); // -2147483647 - Overflow

To prevent this from happening, wrap the code in a checked block. underflow/overflows will then throw an exception

Int32 intMinVal = Int32.MinValue;
Int32 intMaxVal = Int32.MaxValue;

Debug.WriteLine(--intMinVal); // System.OverflowException

Debug.WriteLine(++intMaxVal); // System.OverflowException

As mentoined, this is probably not relevent to the majority of developers. However if you are working with big (Scientific?) data, this may well save yor bacon!

Just tripped up on something that has caught me before!

Having added a CustomValidator control to the page and written the associated client side/server side validation methods I compiled and tested to find the validation methods were not being fired. This is because the CustomValidator control does not fire unless there is a value in the textbox.

“But my control won’t always have a value” you scream!

This is the default value for the CustomValidator controls ValidateEmptyText property, i.e. It is set to False by default.

To fix this, either add a RequiredFieldValidator also, so your users have to enter something, or set the ValidateEmptyText property to True (ValidateEmptyText=”True”).

Like many Android device owners I have recently upgraded my Samsung Galaxy SII to Ice Cream Sandwich (Android v4.0.x). All great and lovely – Still finding/exploring the new features and getting used to the slightly new ways of working in some areas.

I do however have a gripe…and being a driver and music lover, its actually quite a major gripe: Since upgrading I ca no longer control my phone via my car headset. Sure it connects (although this seems much less reliable since the upgrade) and will play, but I have to control it via the the phone, which is actually a big No whilst driving – The Samsung SII is a touch screen only device, all bar the home button/volume/power (like many phones now), so to change tracks for example, I need to look at my phone, instead of the tactile buttons on my car headset which I can ‘touch type’ on, as I can with the steering column control unit.

So – Why is it no longer working? From what I’ve been reading, it seems Google updated the implementation of AVRCP (Audio Video Remote Control Protocol) with Ice Cream Sandwich meaning that software calling the API for functions such as skip track no longer send the expected command. It seems also that this has effected the majority of music sofware for Android, apart from a few, including Google Music.

So – The likes of WinAmp (My choice of music player for Android) will need to update their software to work with the new bluetooth stack. If I could find Google Music on Google Play (Google Play = App Store) I would install and use it – At least until WinAmp is updated (Updated that is, not fixed…as its not WinAmp thats broken!). I’m about to try the Music player that comes with the Galaxy SII…Hopefully that will see me through.

Google are aware of the issue…Lets hope a fix appears soon.


April 2, 2012

On Saturday I attended SQLBITS 2012 (Community day) – Proved to be a very useful and interesting day, great to be amougst some of the best in the industry. I attended 6 of the available 7 sessions:

  • BI From Space: PowerPivot with NASA Data – Mark Stacey
  • Inside SQL Server 2012 ColumnStore Index – Conor Cunningham
  • TSQL Performance Tips – Milos Radivojevic
  • A-Z of Nuggets – UK SQL User Group Leaders
  • Lightning Talks – (Various speakers)
  • Top 10 Administrator Mistakes on SQL Server – Kevin Kline

I would highly recommend this event to anyone who works with SQL server – There was something for everyone, from BI to Dev to Admin, not to mention the great free food and of course prizes from the vendors stands.

Well done and thanks to everyone involved in organising this fantasic event!Image
Kevin Kline presenting Top 10 Administrator Mistakes on Microsoft SQL Server


Vendor stands in the main hall. Competitions, Giveaways and of course the food!
The bacon butties on arrival were most welcome!

My WYSIWYG editor of choice is TinyMCE.

I have recently had a problem where the contents of an ASP.Net text box on a site (TextBox.Text) was empty on postback – Even though text was entered by the user. The text box in question was within an UpdatePanel. The solution is simple – On the button that fires the post back, add OnClientClick=”tinyMCE.triggerSave(false,true);” where tinyMCE is the ID of your TinyMCE instance.


Often, the SQL developer will need to create a stored procedure with an optional parameter. I recently had to do this and could not quite remember the syntax/method. Below is an example of the technique I prefer:

@ParamNullable = null



How does this work?

  • @ParamNullable = null
    This allows the parameter ParamNullableto be null
    ‘COALESCE’ replaces the first value passed to it with the second value if the first value is null,
    so if @ParamNullable is passed into our stored procedure as null, the resuling where clause will be WHERE COLUMN1 = COLUMN1

Very short, very useful tip – Visual Studio 2003 onwards has the concept of a ‘Clipboard Ring’. This means as well as the usual copy (CTRL+ C) & paste (CTRL + V) operation, we can paste from a rolling list of the last 15 entries on the clipboard.

More info:


%d bloggers like this: