X

.NET

Entity Framework Core with .NET Core console application

ASP.NET Core makes it very easy to configure and use Entity Framework Core in web applications. For .NET Core console applications there is no such machinery available but we can still use Entity Framework Core in console applications. This post shows how to wrap database context initialization to separate class and use Entity Framework Core synchronous and asynchronous calls in .NET Core console application.

Select C# version in Visual Studio

Want to try out features of newest of some specific version of C# but Visual Studio 2017 can’t compile it? Well, by default major versions of C# are supported and if some other version is needed it must be turned on from project settings. This blog post shows how to switch between C# versions in Visual Studio 2017.

Ref returns and ref locals in C# 7.0

C# 7.0 introduces ref returns and ref locals. Main goal of these new features is to make it easier for developers to pass around references to value types instead of copies of their values. This is important when working with large data structures that are implemented as value types. This blog post shows how to use ref returns and ref locals in Ć#.

New expression bodied members in C# 7.0

Although expression bodied members have been supported in C# few years there were still room for some new ones. C# 7.0 introduces expression bodied constructors, destructors, getters and setters. This blog bpost goes through all these new expression bodied members and shows how to use them. Also a little peek behind the compilator curtains is made.

Internals of tuple literals

My last post about tuple literals gave brief intorduction to these. This post goes to internals of tuple literals, peeks behind the compiler and shows what happens with tuple literals internally. This post is for developers who are new to tuple literals and want to gain more deep understanding of these.

Performance of compiled queries in Entity Framework Core 2.0

Before applying any optimizations to our code we have to ask one question: what is the cost of improvement and is it really improvement? Compiled queries in Entity Framework 2.0 are categorized as high-availability feature but before making any decisions we need to know what is the actual win. This blog post introduces the measurements I made with simple database context to compare compiled and uncompiled queries in Entity Framework Core 2.0.

Writing IL code on Visual Studio

Microsoft Intermedia Language (MSIL) is .NET assembly language that is standardized under name Common Intermediate Language (CIL). All .NET compilers turn source code to this language. Although we hardly have a situation where we have to write intermedia language (IL) code directly it is still good to know how it works and how it is supported on Visual Studio. This blog post fills the gap and shows how to write IL code on Visual Studio.

How to avoid overlapping timer calls?

Timers are useful .NET feature. With timers we can execute code with specified interval. With real scenarios we can easily face situations where timer calls its callback again but previous call is not finished yet. It may end up with loading some external system too much. It may also end up by making unexpected parallel data processing that distorts the results. This post introduces some options to avoid overlapping timer calls.

Are lock and Monitor the same in C#?

Working on some threading stuff I stumbled upon some discussions about lock and Monitor. Some say they are different and some say they are the same. I took few minutes of time to make some simple experiments with both of these. This blog post shows what C# compiler does with lock statement. As I had to use also Monitor class I added one example here how to use it instead of lock.

Deep dive to async Main

C# 7.1 introduces asynchronous Main method for console applications. It helps us to get rid of some ugly code to await for asynchronous methods. If Main method of console applications is application flow controller that makes multiple calls to asynchronous methods then async Main leads us to much cleaner code. This blog post is my deep dive to async Main.