Using additional NuGet Package Sources on a Build Server

Now we can see the new package source on our machines, and download all kinds of fun things from it. But how do we give other servers (e.g. a build server) knowledge of this new package source? NuGet already thought of this (thank you kindly).  Check out the NuGet.targets file (once you’ve enabled Package Restore on the … More Using additional NuGet Package Sources on a Build Server

Model binding a collection with MVC and .NET 2.0

After about 3 hours of frustrating debugging, I came across a quirk/bug when using: MVC .NET 2.0 / 3.5 Model binding a collection Imagine you have a collection of, say User objects.  And you would like to bind that collection to your view, but you only want to display some of the users.  For example, only admin users.  Your … More Model binding a collection with MVC and .NET 2.0

Unit Testing: Using Extension Methods for better Exception Catching

Improving unit testing, and use some sleek OOP too. Let’s say that we want to test a call to a basic stored procedure, where @ClientID is required. EXEC MYDB.MYSCHEMA.GetClients @ClientID = 10001 Now we want to test the database call in a unit test.  If we don’t pass in @ClientID, we should expect a SqlException, … More Unit Testing: Using Extension Methods for better Exception Catching

DBNull – Using ToString() vs. Casting

You can use ToString on any indexed value in a DataRow, and it will return null if the field is DBNull: string myNullableField = row[“MyField”].ToString(); However, if you try to cast that same field as a string, you’ll get an exception: string myNullableField = (string)row[“MyField”]; //InvalidCastException! But, the good thing about the InvalidCastException being thrown, … More DBNull – Using ToString() vs. Casting