Winter is coming…

Hey blogsters!

Does anyone else feel like this year just flew by? It’s December again, holy bleep!

Personally, it’s been a crazy busy year, especially since my last blog post. I’ve moved continents again, currently I’m living and working in Paris, France, on some of the sweetest tech I’ve ever tasted.

There’s a time to talk the talk, and there’s a time to walk the walk. This year’s been a slow blogging year, but only because I’ve been so busy walking the walk. One day, who knows when, I’d love to be back with a bunch of blog posts. Time will tell if those will be titled along the way of “The best 5 things to make your startup successful”, or “The 5 pitfalls to avoid on your way to success”… Hah!

Anyways, whether you read this post in 2015 or later, I hope you are all doing absolutely amazing!

merry force


Google search tip: excluding old web pages

When searching for anything IT related, google/Bing often return Stackoverflow and CodeProject pages that are old. Really old. Like 2008 old, which often is way too old to still be accurate.

Thankfully, Google has a very simple trick: using the ‘advanced search’ you can limit the search result to pages that have been created/updated in the last ‘hour’, ‘day’, ‘week’, etc. A fixed number of different options are available through the advanced search UI, but Google’s query string has all the power you need… Simply append &as_qdr=y2 to any search URL to limit the search to pages that have been created/updated in the last 2 year.
Possible values for the as_qdr query filter are:
– d(x), where (x) is the number of days, for example &as_qdr=d14
– w(x), where (x) is the number of weeks, for example &as_qdr=w8
– y(x), where (x) is the number of years, for example &as_qdr=y1

Ironically, I found this tip in a blog post from 2007

@Bing: Come on my friend, you’ll never win this way…

Happy 4th anniversary!

Today I am meeting with a customer and he asked me how much LightSwitch experience I have. So I opened my blog’s dashboard, sorted the posts by ascending date, and there it was: my first post ever… Debugging your custom LightSwitch (Shell) Extension, dated July 27th, 2011. What a crazy coincidence, today, to the date, it’s been exactly 4 years since I transmitted my first words into the blog-o-sphere. Happy 4th anniversary guys ‘n guls!

How to make Visual Studio always run as an administrator

There’s a gazillion reasons why you might want to run visual studio as an administrator.
Mine was when installing a Nuget package that tried to run a PowerShell script on install, and complained about the execution policy not being set correctly.
Normally, Nuget automatically sets the PowerShell execution policy for the Visual Studio process itself so that it can run any script. Which might be dangerous, but hey if we were shy of danger we’d be doing something boring like being racepilots and not something adventurous like being developers.What developer would run the same track twice, manually! The dullness…

Anyways, a process cannot set it’s own PowerShell execution policy if it’s not running as an administrator.
Long story short, not running as administrator === not automatically being able to run PowerShell install scripts.

Luckily, I was doing a coding session with a very bright partner of mine, and she told me this trick:
– press Windows+E and go to C:\Program Files(x86)\Microsoft Visual Studio XX.X\Common\IDE
– right click and hit: troubleshoot compatilibity
– let it detect issues for a bit…
– troubleshoot program
– click: “the program requires additional permissions”
– yes, save these settings

From now on, VS will always and forever run as an administrator!


Forget P@ssw0rds, use phrases that motivate you!

It’s a good practice to change your passwords ever so often. If you’re working at a company with IT staff, they’ll probably force you to change your password every month. This is supposed to increase security, but in reality it decreases as people build a system for themselves to help remember what this month’s password was: J@n*05/2015

Since people change their password but not their own formula, changing password adds absolutely no increased security: even first graders can hack the current mutation given an earlier password.

So here’s the idea: stop using a fixed formula, but use phrases that motivate you!

Every month, pick one small goal for yourself. Just a small thing. Something you want to be better at, something you need to build up some courage to do so, something small you want to change. Then, motivate yourself by using that as a password. Since you’ll be typing it multiple times per day, you’ll motivate yourself to actually go do/change/forget/forgive it. It’s like your little personal life coach, whispering a single small goal you can accomplish this month, in your ear, multiple times per day.

Use this system for a year, and I promise you you’ll be happy you did. Here’s a couple to spark your inspiration:

… Yea, had to learn the hard way on that last one…

Feel free to inspire others too, share your favorite motivational password in the comments below!

Changing the ASP.Net web.config connectionstrings at runtime

So here’s an interesting challenge we had to overcome today: every developer in the team has small variations in his/her workstation setup. Instead of micro-managing each installation (we all know how developers love to be micro-managed and even more so how they love to be told how to set up their workstation), we thought we’d give a stab at changing the connections from the web.config at runtime.

Wait, aren’t there a million posts on how to do that already? Well, yes, but most of them use web.config transformations (which aren’t ran when you locally debug), or actually save the web.config (physically changing the file on disk so that the next developer that gets the default web.config is screwed).

What we wanted to do, is actually load the default web.config, but, per developer, change some of the in-memory values.
Turns out, all you need is a little reflection:

        private static void SetConnectionString(string name, string connectionString)
                .GetField("bReadOnly", BindingFlags.Instance | BindingFlags.NonPublic)
                .SetValue(ConfigurationManager.ConnectionStrings, false);
            var connection = System.Configuration.ConfigurationManager.ConnectionStrings[name];
                .GetField("_bReadOnly", BindingFlags.Instance | BindingFlags.NonPublic)
                .SetValue(connection, false);
            connection.ConnectionString = connectionString;

Then, in your global.asax application_start method, before doing anything else:

#if BOB
  SetConnectionString("LocalSqlServer", "wow");
  SetConnectionString("DefaultConnection", "much monkey patch");
  SetConnectionString("AndAnother", "very connectionstring");  

Finally, each developer goes to the configuration manager (the dropdown next to ‘Debug’), creates a new configuration based on ‘debug’, then in the project properties > Build > adds the conditional compilation symbols BOB, CUSTOMCONNECTIONSTRINGS.
Now each developer can run his/her own configuration and manage how they’ve set up their own system, the code that does the monkey patching of the connection strings is not even included in the release output, and the actual web.config file is never modified and will always contain the default values.

Supporting OData $inlinecount & json verbose with Web API OData

OData, the open data protocol is an awesome protocol for exposing data from your server tier, because it allows the caller to use special query arguments to filter, sort, select only particular columns, request related entities in a single call, and do paging.

Basically, this means you end up with an “open” data service API, where you literally just expose data and leave it up to the client to dictate the specific use case. Whether you want to do that is kinda negotiable for your own client, but when you’re building an application where you want to really want to support and nurture users building 3rd party integration tools, OData is the perfect candidate to build an “I don’t know beforehand what scenarios you want to accomplish” API.

Furthermore, creating an OData read service is really simple, you take the Microsoft.AspNet.WebApi.OData nuget package, you expose an IQueryable in your Controller, and you slap on the [EnableQueryAttribute]:

    public class QueryController : ApiController

        public IQueryable People()
            return this.dbContext.People;

So here’s the problem: suppose there’s 100 people in the database, with ages evenly divided from 1 – 100. The caller requests all people with age > 50 ($filter=age gt 50). We also applied a page-size (which you should really always do to avoid self-inflicted DDOS attacks) of 25 maximum records in a single response. At this point, we do not want to just send back 25 records, but we also want to inform the caller that we have a applied a page-size and there are really 50 people that match his search criteria, and wouldn’t it be nice if we can also inform the caller how to get the next page?

The good news is: according to the OData spec, you can! By returning an “OData verbose” response (“verbose” being the opposite of “light”, which is the new OData default response), you can send back a result not only containing the actual results but additional metadata like the number of people that matched your search criteria, and how to get the next page of results.

The really bad news is: the Web API OData implementation does not support the $inlinecount query parameter (which instructs the server to send back the count after filtering but before paging). OUCH!

Weirdly, after following a dozen blog posts (like this really good one ) I stumbled upon the fact that this is only partly true… The Web API Odata implementation does in fact support the $inlinecount query parameter, however it does not in any way support actually sending back the JSON verbose format where the caller actually gets to see the query parameter…
Wait, whot?
A caller can send the $inlinecount, the EnableQueryAtrribute (which really does all the heavy work) will correctly handle it, but instead of properly sending the count to the client it will simply keep it in memory and send only the results back. Same story with the link to the next page of records, when you implement a PageSize.
So the good news is: to re-enable the $inlinecount, or in other words: send back a more verbose response to the user, you can make your own EnableQueryAttribute:

using Newtonsoft.Json;
using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Filters;
using System.Web.Http.OData;
using System.Web.Http.OData.Extensions;
using System.Web.Http.OData.Query;

namespace Lobsta.webapi
    internal class ODataVerbose
        public IQueryable Results { get; set; }

        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
        public long? __count { get; set; }

        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
        public string __next { get; set; }
    public class QueryableAttribute : EnableQueryAttribute
        public bool ForceInlineCount { get; private set; } 
        public QueryableAttribute(bool forceInlineCount = true, int PageSize = 25)
            this.ForceInlineCount = forceInlineCount;
            //Enables server paging by default
            if (this.PageSize == 0)
                this.PageSize = PageSize;
        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
            //Enables inlinecount by default if forced to do so by adding to query string
            if (this.ForceInlineCount && !actionExecutedContext.Request.GetQueryNameValuePairs().Any(c => c.Key == "inlinecount"))
                var requestUri = actionExecutedContext.Request.RequestUri.ToString();
                if (string.IsNullOrEmpty(actionExecutedContext.Request.RequestUri.Query))
                    requestUri += "?$inlinecount=allpages";
                    requestUri += "&$inlinecount=allpages";
                actionExecutedContext.Request.RequestUri = new Uri(requestUri); 

            //Let OData implementation handle everything

            //Examine if we want to return fat result instead of default
            var odataOptions = actionExecutedContext.Request.ODataProperties();  //This is the secret sauce, really.
            object responseObject;
            if (
                && actionExecutedContext.Response.TryGetContentValue(out responseObject)
                && responseObject is IQueryable)
                actionExecutedContext.Response =
                        new ODataVerbose
                            Results = (IQueryable)responseObject,
                            __count = odataOptions.TotalCount,
                            __next = (odataOptions.NextLink == null) ? null : odataOptions.NextLink.PathAndQuery

        private bool ResponseIsValid(HttpResponseMessage response)
            return (response != null && response.StatusCode == HttpStatusCode.OK && (response.Content is ObjectContent));

Note: this is highly opinionated sample code, it always uses a page size of 25, and always returns the inlinecount… Change to your liking, by example checking if the requested format is jsonverbose, to be OData spec compliant
Finally, replace the ‘EnableQuery’ attribute with our custom one:

    public class QueryController : ApiController

        public IQueryable People()
            return this.dbContext.People;

Putting it to the test, I called: /api/query/people?$orderby=name&$filter=age gt 50&$inlinecount=allpages again and now correctly receive my requested metadata:

   {"age":51,"name":"Anna"} /* More results were included of course */

Meet the new love of my life, her name is

YEZZZZ! I can finally start spreading the love of the goodness that is named Aurelia, with which I’ve secretly been in love with for a while now. I meant to write about her last week, but an NDA contract prevented me from bragging about her beauty before Rob did.

Wait, who’s rob? Who’s Aurelia? What does this have to do with anything? How does it affect me? And you?


Rob Eisenberg’s one of the most genius architects of our era. I’ve been a fan of his work since the Caliburn days, a framework he wrote which made MVVM for WPF/SL/WP/… as easy as possible by reducing boilerplate code and using conventions instead.  Over the last couple of years, Rob created an HTML/JS framework named DurandalJS, a masterpiece which never got the credit it deserved.  Well, except from the fine folks at Google, who hired Rob to help build out the next generation of their popular AngularJS framework.

Late 2014 however, Rob left Google because his colleagues were not as visionary as he was (my words, he was more diplomatic in his goodbye message) and started assembling a team of world-renowned experts (and me) to focus on the first of the next-generation javascript frameworks…


So ok, enough about my man-crush on Rob and his hyperthreaded brain, let’s focus on this beauty of this open-source framework that’s called aurelia. Why would this framework be any better than it’s “competitors”, like EmberJS or the next AngularJS?

I could copy its major strengths from the homepage,  but I’d rather highlight three really important ones (which is not to say you shouldn’t head over to right now to look at her in her full glory):

  1. ES6. If clarification is needed: ES6 is short for EcmaScript 6, the next generation of javascript. It’s just a (finished) specification at this point, since none of the major browsers actually fully support ES6 yet, so aurelia is written in ES6 but then ‘compiled’ into current javascript (ES5).  In the gitter channel, an open chat channel where you are all welcome to discuss anything aurelia, I’ve seen Rob look at the next-next HTML (thus: HTML7) specs, to analyse how we should build the best (most future-compatible) API’s. Long story short: Aurelia is ready for the future, today.
  2. MV* architecture with conventions. Lots and lots of conventions. Aurelia assumes a ton of things out-of-the box, and you can add your own conventions. Got a VM named customer.js and a V called customer.html? Aurelia saw what you were trying to do there. It wasn’t that hard to get either, so why should developers have to write code/configuration to bind those two together? Write code only once and especially: avoid writing unnecessary code (and yes if you don’t like a convention you can always override it). Which seamlessly brings us to the next highlight:
  3. Extensible HTML… As a technology enthusiast, I get a nerdgasm just looking at aurelia. However if one must build large LOB applications, writing HTML all day is too granular to make any kind of progress. However, thanks to aurelia’s extensible HTML compiler, things like <barChart xAxis.bind=”months” yAxis.bind=”sales” /> all the sudden, become valid HTML.


Think about that for a moment…

This means that me and you and anyone can write reusable building blocks which are an abstraction level higher than HTML, without actually hiding/losing control over the underlying technology stack!

Me? You?

You and me shared a love for RAD,that’s for sure. And Aurelia is not RAD at all and certainly not a better version of anything like LightSwitch.


Aurelia is only the tip of the arrow currently loaded on my bow.

Late last year, three of my LightSwitch customers (and two more are in discussing phase) and I actively started looking at a newer tech stack to phase out LightSwitch if the day would ever come LS is announced ‘dead’.

We looked at so many RAD frameworks and were impressed by a quite a few, but convinced by none. Most RAD frameworks work great for small and simple CRUD apps, but suffer from either poor testability, modularity, scalability, extensibility, most likely all of the above.

Hence, we’re currently building out a super-framework ourselves based on Entity Framework, Web API (CQRS architecture) and aurelia. I use the term super, not only because it is super and kicks ass, but mostly because the intent of our venture is to take all boilerplate and repetitiveness out, and build out applications using a ‘higher abstraction of code’. A super-set of traditional code. Much like LightSwitch used graphical designers as a higher abstraction of all the code goodness it generated “under the hood”, however this time we’ll still have full control of what’s on top of the hood, “under the hood”, and the hood itself.

This’ll keep me very busy during the first part of 2015 (during which I still have LightSwitch projects and will share whenever I can share any LS goodies), then afterwards will undoubtedly be a large part of my future for quite some years to come. Perhaps your future too, as it’ll all be open for your LOB app development pleasures. If you’re in a position where you need a modern, open and future-proof stack for business app development now, please do get in contact so we can work together asap, or at least let me know about your special requirements so I can make sure we can develop this thing as smart as possible.

The future starts today. I haven’t been so excited about tech since a few years ago and am really happy to be a part of, from the start of, this beauty.  Aurelia really is the first of a next generation of frameworks, you owe it to your future self to take her out for a spin. If not today, then tomorrow.

If she looks too high-tech or too granular for you or to make LOB apps today, give it a little bit of time too. We’re at the start of this journey and I’ll put in the effort to make sure she’s worth the venture!


So what’s the deal with that announcement?!?

I wish I could tell you. No seriously, I deeply apologize for the extreme hopes my last post left, but I’d be breaking my NDA if I’d talk of this before the official announcement, which was planned for today but apparently needs a little more preparation before it’ll take public form.

Perhaps, no surely, I shouldn’t have put a specific time-frame in my last post.

I hope tomorrow, or later this week, I can undo this disappointment of this post and wash off the smell of rotten tomatoes, that you may now rightfully throw at me, by sharing the goodness that is this novelty with you!!

New Syncfusion eBook: #LightSwitch mobile business apps Succinctly

Proud to present: Syncfusion’s newest addition to their Succinctly series: LightSwitch mobile bussines apps, written by yours truly.

Image 096


The first eBook I wrote for Syncfusion, LightSwitch succinctly, was a small introduction to LightSwitch’s designers, server, and desktop client (Silverlight).  I got some great feedback so when Syncfusion asked me (some time last year) to write a follow up, I was honored and anxious to get started. I was even more honored when I found out my technical reviewer was community champion Alessandro Del Sole!  (Thanks man!!)

This book picks up where the first one left off, describing some newer features like the DB projects and (of course) the HTML client.  I did some pretty advanced looking UI customizations, and was surprised myself in how easy the HTML client actually is to customize…

I hope you enjoy this one as much as I did writing it!

Keep rocking LS!