With the release of ASP.NET Core, configuration was given a major upgrade. The new options API provides the ability to add configuration sections to the service provider and then inject them using the options interfaces. Unfortunately, I still see people injecting IConfiguration and then manually grabbing values with strings.Continue reading “Configuration in ASP.NET Core”
If you’ve been working in ASP.NET Core then you’ve probably been faced with the dilemma of choosing between using middleware or filters. Both middleware and filters can serve similar purposes. Choosing between them comes down to whether you need access to the MVC context.Continue reading “Middleware vs Filters ASP. NET Core”
In the first five years that I was working as a developer I didn’t once bother to read the .NET framework source code. I’m going to go out on a limb and say that this is probably the case for most software developers. We work with the .NET framework and associated tools and libraries every day, but we seldom care about how they really work or what’s contained within. Now, don’t get me wrong, the whole point of a framework is to shield you from having to know the underlying implementation details and knowing the entire framework is not necessary. I would argue though that knowing parts of the framework and how they work opens up opportunities and affords certain benefits.
Continue reading “Why You Should Read the .NET Core Source Code”
If you’re using Entity Framework Core and building any non-trivial enterprise application then using data tables with paging is almost a certainty. There are two ways to do this: server side and client side. Which one you choose depends on your design and your needs. There are pros and cons associated with both so you need to choose the correct approach for what you want to accomplish. Continue reading “Paging in Entity Framework Core”
Entity Framework Core query performance is something that comes up often when working on projects that rely on it heavily. I have often heard that Entity Framework is not performant enough which then leads to everything being written as a stored procedure. Usually this happens for two main reasons: developers aren’t familiar with how to write queries in a performant manner and developers that are more comfortable with SQL want to develop everything in their technology of choice. Entity Framework is not a silver bullet for everything. There are times when it simply can’t deliver the performance needed or when it is simply functionally incapable of doing what is necessary due to limitations of the framework. That being said, there is no reason you can’t write the vast majority of your application with it and reap all the benefits it provides.
Continue reading “Maximizing Entity Framework Core Query Performance”
In part one we set up our IdentityServer4 project and our data and core projects. If you haven’t read part one, you can do so here. In part two we’re going to add in an Angular web application using the implicit flow and an API that the web app will interact with. You can see the full source code here.
Continue reading “IdentityServer4 in ASP.NET Core Part 2”
Continue reading “IdentityServer4 in ASP.NET Core Part 1”
Let me preface this blog post by saying that there are still times when a DTO makes sense. Also, this post is written from a .NET perspective, so some things may be different on your platform. What I want to address though is the tendency of many developers to just automatically create a set of DTOs for each layer for each domain model. As I mentioned in other blog posts, you should always think about why you are doing something before you are doing it. Continue reading “Think Before You Use The DTO Pattern”
That is, it’s dead if you are using Entity Framework Core. If you’re still using straight ADO.NET, or even just dapper, then the repository pattern still probably makes sense for you. If you’re using Entity Framework, then you really aren’t gaining much from doing so anymore. Five years ago, you could reasonably argue that it was beneficial to use the repository pattern, or some form of abstraction, over entity framework for the following reasons:
Continue reading “The Repository Pattern is Dead If You Use Entity Framework”
If you’ve worked with Asp.Net Core to create APIs then you have more than likely run into situations where you needed to return different sets of data for the same model. One way to accomplish this is request post processing using an ActionFilter. Lets start with a common scenario. We have an internal enterprise application and we have different types of users in the system. Users can call our API to get data on other users depending on their permission levels. We have three different types of users: Admin, HelpDesk, and Employee. Our class looks like this:
Continue reading “ASP.NET Core Request Post Processing”