Practical .NET


Coding Without a Plan

I don't believe in coding design tools. I've been programming for more than 30 years now (40 years if you go back to my first class in programming). I think in code. Code is my design language and procrastination is my friend.

Let Other Processes Run When Debugging One Process

When you hit a breakpoint in Visual Studio, everything stops. If you'd rather other processes keep running, you can enable that.

Looking at Entity Framework Core 1.0

There's more (and some less) in Entity Framework Core compared to Entity Framework 6, at least in version 1.0. While you can move to Entity Framework Core now, it might be too early for you.

Ensure Consistent Testing with Mock Objects and Moq

If you run an automated test and your test fails then you want to know that it's your fault -- not a problem in someone else's code or the result of a change in your test data. Moq lets you do that in two lines of code, even if your code uses the ASP.NET Session object.

ORM-Less Data Storage with Document Databases and Marten

Document databases are a form of NoSQL database that may store all of the information for a given object in a single instance in the database.

Leverage Joins in Entity Framework To Get Just the Data You Want

Every once in a while you'll need to use the LINQ Join to get the data you want.

Speed Up Skip and Take in Entity Framework with Lambda Expressions

If you're using Skip and Take in LINQ to page through your data, a tweak to your syntax can cut your response time by as much as 10 percent as you page through your data.

Testing Experimental Code in Production with Scientist.NET

A .NET port of the Ruby library allows for experimental testing of code that's gone to production.

Testing Only the Code You Write: Isolating Components with Moq

When you're testing an ASP.NET MVC controller (or, really, any class at all) you want to make sure the code that fails is the code you're testing. Moq provides a simple way to isolate the code you're testing and lets you generate test cases.

Best Practices for Lazy Loading in Entity Framework

Sometimes you want child objects retrieved with the parent object, and sometimes you don't. What you NEVER want is to retrieve child objects accidentally. Here's Peter's advice on how to get the best performance when loading child objects.

Setting the Order of Your Script Files

Script bundling speeds up your application by reducing the time it takes to download all of your JavaScript code. But you'll need another object to get your files added to the page in the order you want.

Organize Your Tests to Reduce Overhead

In test-driven development, you have to decide how you'll divide your test methods between your test classes. The best solution is the one that requires the least effort on your part and implements the Single Responsibility Principle for tests.

Defining Columns, Primary, and Composite Keys in Entity Framework

There are two attributes you can put on your entity class properties: one is a convenience, the other is essential, and both are required when the primary key for a table consists of two columns.

SpecFlow Two-Step Parameter Conversions

Here's how to use SpecFlow to convert plain-text scenario steps into .NET types.

Creating HTML Helpers You Can Use in Any ASP.NET View

An HTML Helper is a bit of Razor code that can be called from multiple places in a View. But, if you put your Helper in the right place, you can also use it from any View in your application.

Subscribe on YouTube