.NET
No need for repositories and unit of work with Entity Framework Core
After working again on codebase where Entity Framework Core was used through repository and unit of work patterns I decided to write eye-opener post for next (and maybe even current and previous) generations about what Entity Framework has to offer in the light of these to patterns. In many cases we don’t have to move away from database context approach but stick with it even more than we first planned. Here’s how many useless repositories and units of work born and here’s also how to avoid these and go with implementations offered by Entity Framework Core.
Generalize file access for ASP.NET Core applications using IFileClient implementations
Once upon a time I worked out simple file client generalization so my applications can keep files on local machine or somewhere on the cloud without changes in application code. This blog post shows how to generalize file access in web applications and provides implementations for local and cloud file clients.
Reading Windows and Linux memory metrics with .NET Core
Until .NET Core gets its own cross-platform system metrics support I needed something simple to get system memory metrics of servers where ASP.NET Core application is running. I wasn’t able to find a nice solution but I still worked out something to get system memory metrics with .NET Core on Windows and Linux.
Self-contained executable with .NET Core 3.0 on Windows, Linux and Raspberry
.NET Core 3.0 comes with support for self-contained executables. It means we can publish applications as a single executable for specified platform. Also trimming – removing of unused code from assemblies – is supported. This blog post demonstrates how to build self-contained executables using .NET Core.
Dependency Injection in Azure Functions
Azure Functions V2 supports ASP.NET Core like dependency injection. It is specially good if we write functions that are wrappers for shared libraries and components we are also using in web and other applications of our solution. This blog post shows how to use dependency injection in Azure Functions.
HttpClient: How to remove charset from Content-Type header
I was writing client library for one online service and faced situation where I had to remove charset definition from Content-Type header. It was like content type is application/json or response is 415 “Unsupported media type”. I was using HttpClient class to communicate with service and without additional efforts charset doesn’t go away. Here is how I got charset definition away from Content-Type header.
Serializing objects to URL encoded form data
While messing with dictionaries to create form data for FormUrlEncodedContent so I can send data to server using HTTP client, I started thinking about easier and cleaner way to do it. I was writing integration tests and I wanted to re-use some model classes instead of dictionaries. Here’s how to do it. Sample of integration test is incluced.