In this blog post, we will explore few hidden gems in list patterns , which was introduced with C# 11. List Pattern allows us to check patterns in arrays or list. Assign Variable You can assign variables using pattern, provided the pattern matches. For example, var arr = new [] {1,2,3,4,5}; if(arr is [_,2,var third,..] match) { … Continue reading Hidden gems in List Pattern
Month: February 2023
Install Extensions in Postgres Docker container
Recently I wanted use the Fluent migrator for seeding my postgres database, which was running as a docker container. I basically had a table User, which had a primary key of type UUID that needs to be auto-generated. My migration code looked as follows. Create.Table(User.TABLE_NAME) .WithColumn("id").AsGuid().NotNullable().WithDefaultValue(SystemMethods.NewGuid).PrimaryKey() .WithColumn("username").AsString().NotNullable() .WithColumn("password").AsString().NotNullable(); The above code would essentially turn out as the following postgres sql. … Continue reading Install Extensions in Postgres Docker container
Create Mongo Replicaset using Docker Compose
In this blog post, we will attempt to create MongoDb replicaset using docker compose. A replica set in mongodb is a group of mongod instances which maintains the same set of data. This enables applications to work despite one of the db servers going down. At every instance, there wil be only and only ONE primary node. Rest of the … Continue reading Create Mongo Replicaset using Docker Compose