.NET
Cost of exceptions
Hopefully the era of leprosy and corona is over for this time and it’s time to get back to blogging. Exceptions are powerful feature of object-oriented languages as far as they are used like they are thought to use – throw exception only when something really unexpected happens. This advice should be taken seriously – here’s why.
Top-level programs in C# 9.0
C# 9.0 comes with nice new feature called top-level programs. It’s something that teachers of beginner classes will love for sure. Imagine – you start teaching C# with only two lines of code on screen. All missing code is generated by compiler. This blog post introduces top-level programs and shows some secrets of new C# compiler.
Xamarin Forms turns to .NET MAUI – single project and code-base dev experience
Yesterday Microsoft announced .NET Multi-platform App UI (MAUI) – the effort to turn Xamarin Forms apps use single cross-platform code-base targeting multiple platforms. Demos from Build conference yesterday gave clear signal – it’s not just an experiment but real deal. They really had single project running on Windows desktop and iPhone. This blog post is short overview of what’s coming.
Implementing repository querying interface in EF Core DbContext
My last bold statement was that we don’t need custom unit of work and repository classes with Entity Framework Core. One issue remained unsolved and it was querying part of repositories (yeah, those custom querying methods). After some experiments to get querying interface of repositories to DbContext I worked out something that I kind of like. I managed to make DbContext to work like classic unit of work that hosts repository instances. Here’s my experiment and the solution I worked out.
Behind the compiler: 20 examples of C# code before and after compiling
Over years I have written many blog posts about C# and .NET that demonstrate also how things work internally and what C# compiler produces from the code we write. I have called these chapters usually as “Behind the compiler”. This post is growing list of my writings covering interesting findings about C# compiler work.
Execute raw SQL commands in Entity Framework Core
I have never seen a real-life project where object-relational mapper generates 100% of needed SQL. There have always been those special cases when custom SQL commands are needed. In this post I will demonstrate how to run custom SQL commands in Entity Framework Commands and how to read data from database without DbSet and query types.
Using Windows Forms DataGridView in .NET Core 3.1
Windows Forms is coming to .NET Core and last version of Visual Studio 2019 Preview comes with form designer built in. There are basic controls available in toolbox but not all out-of-box controls have made their way there. One of these is DataGridView. Although not shown in toolbox, DataGridView still works like expected. Here’s how I made it work.