Archive
Showing posts from 2016.
What to do if Visual Studio won't download the DLL for a NuGet package
One annoying problem is when sometimes you try to build your solution, only to get a pile of compilation errors due to a missing DLL. This is often caused by one of the DLLs not downloading from NuGet. The package will be in packages.config, but only the .pdb file gets downloaded.
Even more annoying is when you're the only developer to have this problem. Everyone else can build the solution without problem.
The answer is fairly simple, but not obvious. Read more for the details.
How to sort and filter on a child entity when using Include()
It seems we aren't the only ones to find filtering and sorting child entity collections unnecessarily painful. Someone has been kind enough to write a Nuget package (part of a suite of them by the looks of things) that simplifies your code significantly.
This package removes the need for some of the tortuous hoops we had to negotiate before.
How to unit test a repository that uses DbContext with NSubstitute
A fairly standard set up for me is to have a solution in which I have a Data project that contains an EF6 .edmx file, generated from an existing database. I then split the entities into a separate Entities project, and have a Repositories project that references them both.
The problem was, I wanted to write unit tests against the code, but couldn't work out how to do it. This post shows what didn't work, and then what did.

Implementing a testable "Are you sure?" pop-up in MVVM
A few years ago, I blogged about how to implement an "Are you sure" pop-up in MVVM. Well, I've grown up (a bit) since then, and realised that the code there wasn't testable. I therefore take great pleasure in presenting for your delight, a testable "Are you sure" pop-up in MVVM. Aren't I kind :)
Being good boys and girls, we want to write testable code, so if by some miracle we ever get around to writing unit tests, we can run them safe in the knowledge that they stand a fetid dingo's kidney's chance of working! One of the main issue involved here is ensuring we keep all view-related code out of the view model.
This post explains how to do it (with some pointless pictures)
Project Euler - Problem 14 Longest Collatz sequence, or "What I didn't learn from problem 8"
As my regular reader will doubtless remember, I recently blogged about the important lesson I learnt while solving problem 8 . I prophetically commented there...
"So, am I going to contemplate my problem domain before diving in and coding next time? Probably not, but at least if I don't, I might have some idea where to look when the bug reports come in!"
Hmm, I thought I was joking! Well, sadly I wasn't.
Project Euler - Problem 8 Largest product in a series, or "What I learned in school today"
As I briefly mentioned in my rant about the F# fanboy lies , I have been using Project Euler to help me learn F#. I have got as far as problem 8, which was to find the largest product in a series of digits.
Apart from the fact that this was an interesting problem, I learnt a very important lesson from this one, and thought it worth sharing.
Seeing through the F# fan boy lies
As my regular reader will know, I love anything shiny and new, and so was intrigued when I came across F#. When I was an undergraduate (some 25 years ago, ulp!), I played around with Prolog, and enjoyed the different approach to programming it offered.
However, as my time in front of the computer is at a premium, my F# learning started off with reading books and blog posts late away from the computer, usually last thing at night, and not actually doing any coding. Like most C# developers who come across F#, my initial reaction (other than “Hey, that’s shiny and new, I want to learn it!â€) was “Why?†If you search around for terms like “why f#†and “c# vs f#†you’ll find that this is a very common question.
The problem is that the answers aren’t very good. Well, let’s be blunt, there are a lot of lies out there.