C# Language Mind map
This blog post contains a mind map of language features starting from C# 1 up til now - including some of the new C# 12 features that will be released in November 2023.
Hey, I'm Steven a .NET Developer in Switzerland. I am a Microsoft MVP. Also, this blog is open source on GitHub.
This blog post contains a mind map of language features starting from C# 1 up til now - including some of the new C# 12 features that will be released in November 2023.
In this blog post, we'll dive into the ins and outs of the repository pattern and examine both its benefits and its potential drawbacks. We will start from the very basic to some more advanced use cases. So let's dive right into it.
.NET 6 brought us two new datatypes: DateOnly
and TimeOnly
. For those types we don't have any first class support in Entity Framework - until now.
There is a recent change, that hit us with Entity Framework 8 that might ease the situation and brings native support for those types.
Did you ever hear the word "compiler magic" or "syntactic sugar"? Probably yes and therefore we want to dissect what this "magic" really is!
We can see how we can predict performance or bugs by "lowering" our code. Also we will see how things like foreach
, var
, lock
, using
, async
, await
, yield
, anonymous types, record
, stackalloc
, pattern matching, Blazor components, deconstructor, extension methods... do not really exist.
... if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.
This is written in the Linux style guide. Let's see why they have that rule and how we can overcome deeply nested code.
Another new C# 12 feature might drop soon and makes its debut with the next iteration: Primary Constructors.
The blog post will talk about what a Primary constructor is, why we already have it, and what the proposal tries to change. Exciting times are ahead of us!
Cohesion represents the degree to which the elements of a module belong together. A module or class is said to be highly cohesive if its methods and data are highly related, meaning that a change in one affects just a small number of elements.
We can use this metric to know whether or not an object is in a good shape or needs some refactoring.
The next iteration of Entity Framework, namely Entity Framework 8, will have a new and exciting feature:
Support raw SQL queries without defining an entity type for the result
That means less boilerplate code!
Pagination is the process of dividing a set into discrete pages. In the context of Entity Framework, that means we are only getting a certain amount of entries from the database.
And we will implement a very easy solution to make that happen in 3 steps. The result will look like this:
var pagedList = DbContext.BlogPosts.ToPagedList(page: 1, pageSize: 5);
I often read that Task
is used for multithreading in C# / .NET, but that is not the case. And it is crucial to understand why this isn't the case. We will also see which problem exactly Task
is solving in the first place.