X

.NET

NotSupportedException: No data is available for encoding 1252

Another day, another surprise on .NET Core. Tried to load a file with Windows-1252 encoding and got the following exception: NotSupportedException: No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. Here’s how to solve the problem.

Unit testing multi-tenant database provider

My saga on supporting multiple tenants in ASP.NET Core web applications has come to point where tenants can use separate databases. It’s time now to write some tests for data context to make sure it behaves correct in unexpected situations. This post covers unit tests for data context and multi-tenancy.

Global query filters in Entity Framework Core 2.0

Entity Framework Core 2.0 introduces global query filters that can be applied to entities when model is created. It makes it easier to build multi-tenant applications and support soft deleting of entities. This blog post gives deeper overview about how to use global query filters in real-life applications and how to apply global query filters to domain entities automatically. (more…)

Like-operator in Entity Framework Core 2.0

Entity Framework Core 2.0 was announces yesterday and it brings some new and cool features. One of them is SQL Like-operator we can use now using directly in our code. Here is the example of using new Like-operator.

Converting System.Drawing.Color to hex

One quick code note to make during building my Azure Cognitive Services demo application. I needed a way how to convert colors of System.Drawing to hex strings that I can use in views. Here is my simple and elegant solution.

Running PHP applications on .NET Core

Ever wondered about mixing up simplicity and flexibility of PHP with power and performance of .NET Core? The solution is coming and it is called Peachpie, the successor of Phalanger. This blog posts introduces Peachpie - the tool to compile PHP code to .NET Core - and helps to get started with it. (more…)

Local functions in C# 7.0

One of new features of C# 7.0 is support for local functions. Local functions are methods that are defined inside other methods to simplify more complex code and by example to support local recursion. This blog post shows how to use local functions in C# 7.0 and gives some advice in context of technical design of code.

Simple .NET Core application using VB.NET

.NET Core 2 Preview 1 bits bring us support for VB.NET on .NET Core. Although tooling for web applications is not ready yet we can start with console applications and also some web applications like I will show in some of my later posts. Visual Studio 2017 Preview 2 is needed to try VB.NET out on .NET Core. This blog post is short demo about how to build simple utility application on .NET Core 2 Preview 1 using VB.NET.

Throw expressions in C# 7.0

C# 7.0 introduces throw expressions. We can add exception throwing to expression-bodied members, null-coalescing expressions and conditional expressions. This blog post introduces throw expressions, demonstrates how to use them and also provides a peek behind a compiled throw expressions.

Tuple literals in C# 7.0

C# 7.0 brings some new features to tuples and with code editors that support these new features we can use tuples with named members instead of names like Item1…ItemN. This blog post goes through practical example that demonstrates how to move on classic method that returns multiple values to new tuples.