OJ Develops

Thoughts, tips, and tricks on software development. .NET | C# | Azure

Converting JSON Data Into C# Objects

12 May 2016

There are times when we would need to convert JSON string data into C# objects. An example would be when consuming some Web API that returns JSON data. Although we can work with the JSON string data directly, it would be much nicer if we could somehow convert the data into an object, so that we can work with them more easily. In this post we will talk about how to do this.

Read More

Libraries and Frameworks

09 May 2016

Today we are going to take a look at libraries and frameworks. We will describe each of them and take a look at some examples for each. We will also take a look at a practical example of how being able to distinguish between the two will help us in our daily coding.

Read More

Why Use ViewModels?

02 May 2016

Let's talk about a simple but important topic - why use viewmodels in our web applications. Specifically, the kind of viewmodels that we will be talking about are the ones that are used as parameters or return values in controllers.

Read More

Introduction to Dependency Injection - Part 2

28 April 2016

In the last post I gave an introduction to dependency injection, where I described what it is, how it can be achieved, and the motivation behind it. We left off by providing an example in an ASP.NET MVC controller, where we manually "newed up" dependencies inside the constructor of a controller. In this post we will take a look at dependency injection frameworks and see how they can help us manage dependencies.

Read More

Introduction to Dependency Injection - Part 1

25 April 2016

The concept of dependency injection has been around for a long time. But now that dependency injection is baked into ASP.NET Core 1.0, I thought it would be a good time to write about what it is and why and how we can take advantage of it.

Read More

Creating Custom Filters in ASP.NET MVC

21 April 2016

Whenever ASP.NET MVC receives an HTTP request, the request goes through code in the MVC framework before it reaches our controller actions. And then, after we return from our controller, it also goes through framework code before an HTTP response is emitted. The framework code that is involved is typically called the "pipeline". In this post we will talk about how we can insert our own custom code into the pipeline. This is achieved by creating special classes called filters.

Read More

Creating a Generic Lookup Service

16 April 2016

In a previous post I talked about how we can manage lookup tables with Entity Framework Code First. In that post I suggested using the primary key directly to check for a specific lookup, rather than introducing an arbitrary column that will serve as an identifier. In this post I will talk about how we can make a generic lookup service to simplify how we show lookup values in, say, dropdown lists.

Read More