Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

2025-04-16

It Works on My Machine™

Sometimes you get nipped in the butt by a small, usually insignificant detail that just happens to be significant in your specific situation. Today I ran into such a "gotcha", and it reminded me of a story that fits nicely.

2021-11-12

Using Data Protection in Entity Framework Core with Value Converters (v1.1)

This post is intended as an addendum on Mgr. Jiří Činčura's excellent post Using Data Protection in Entity Framework Core with Value Converters (archive 1, archive 2). In it, he explains how you can use an Entity Framework Core ValueConverter to encrypt data before it being stored in the database and decrypt it when reading from the database.

2021-07-06

Storing IP's and networks in SQL Server efficiently

When you Google on how to store IP addresses efficiently in SQL server few approaches keep coming up. Most of these approaches most notably tend to 'forget' about IPv6 and work exclusively for IPv4 IP addresses. Other approaches use a (var)char to store IP addresses and this works fine, as long as your (var)char allows up to 39 characters if you want to be able to handle IPv6 IP addresses. It'll also work fine whenever all you need to do is store an IP address or maybe even search for a specific IP address, such as in logging scenarios, where you can write SELECT * FROM MYTABLE WHERE [ip] = '192.168.0.1'. However, when storing networks (such as 192.168.0.0/24 in CIDR notation) things get a bit harder. If you want to find all networks that 'contain' a given network you're in for some trouble. Another solution is to store IP's as (var)binary. Again, most solutions I found only worked with IPv4 but it's perfectly possible to store both IPv4 and IPv6 IP's in a single (var)binary field.

2019-02-27

Handling multiple implementations of an interface with Dependency Injection in .Net Core

When you have an interface with multiple implementations and you don't want to use a 3rd party DI framework, you'll need to work around some limitations of the 'native' DI implementation in .Net Core.

2018-08-16

Swashbuckle custom ordering of controllers

By default, Swagger (or rather: Swashbuckle) orders the documentation of controllers by controllername. So if you have a FooController, BarController and BazController they will be ordered as Bar, Baz, Foo in the swagger UI. Let's change that.

2014-10-21

MongoVue GridFS bug

I have been a MongoVUE user for some time and have always been quite happy with it. I had a bug or problem a few years ago (can't remember what exactly) and was quite astonished that their site doesn't feature a "support" section. All you can do is click "contact us" and fill in some crappy e-mail form. Back then, if I recall correctly, it must've done the job because the bug has been fixed (I guess).

2013-04-26

A TimerWheel implementation in C# with flexible rescheduling

Recently we started a project that, among a lot of other stuff, required many objects to be scheduled (and rescheduled) for processing. Each of these objects could, potentially, require it's own interval; for example object A could be required to process each 10 seconds, object B could need an interval of 3600 seconds and object C could need to be processed each second. As long as there's a handful of objects, instantiating a timer for each object would be an option. But since our collection could grow to contain more than thousands of objects I felt that having a timer hanging around for each of those objects wasn't the best idea ever. This was just a gut-feel until I later stumbled upon a blog-post from one of my all-time favorite bloggers Raymond Chen. Although, apparently, it's okay to have many timers lying around I felt there had to be a more efficient way to solve my problem.