Taswar Bhatti
The synonyms of software simplicity
Category: C#
Redis

Redis Transactions Redis provides a way to do Transactions, but the transactions are somewhat different than what you know from a SQL Relational Database perspective. In SQL Relation Database world you can executed partially and then rolled back the entire transaction. While Redis uses the MULTI and EXEC commands where every command passed as part […]

Redis

Redis Pub Sub, somehow may sound weird that it provides such a functionality since when you think of Redis the first thing that comes to mind is of a cache key value store. But indeed Redis does allow us to use the messaging paradigm by using channels to publish messages and for subscribers to listen […]

Redis

Redis Sorted Sets are similar to Sets, with unique feature of values stored in Set called scores. The score is used in order to take the sorted set ordered, from the smallest to the greatest score. Just like in Sets, members are unique but scores can be repeated. Sorted Sets are ideal for storing index […]

Redis

In the second blog post series “Redis for .NET Developer” I will show how we will use C# to connect to Redis. We will be using StackExchange.Redis library to connect to Redis. One can download StackExchange. Redis through NuGet. StackExchange.Redis is a high performance general purpose redis client for .NET languages (C# etc). 1. Let’s […]

Redis

What is Redis Redis (REmote DIctionay Server) is a very popular open-source, networked, in-memory, key-value data store, sometimes referred to as a data structure server which also comes with optional durability. Redis is well known for high performance, flexibility, provides a rich set of data structures, and a simple straightforward API. The programming language Redis […]

linq

Here is a quick C# tip of counting up values of a Dictionary<TKey, TValue> where the values contains a List<T> using Linq. Lets say you have a Dictionary that contains Dictionary<string, List<Guid>> and you wish to find out how many items of Guid you have. You can easily do it by the Sum Linq aggregate […]

dotnet C#

Here is a quick C# tip, when using string compare don’t use

use the Equals and StringComparison.InvariantCultureIgnoreCase enum.

The thing you need to note is which rules are appropriate current culture, the invariant culture, ordinal or another culture entirely. One can create the compare from StringComparer.Create(culture, true)

dotnet C#

Here is another C# tip. Most of the time when you are trying to get a value from dictionary you would try to check if the key exist or not something like.

But one can use TryGetValue

The benefit of using TryGetValue is that the dictionary is synchronized, there is no race condition.

WPF

Here is a hint when using WPF and you may come into a situation where you want to databind an element to its Parent ViewModel. As an example lets say you have a view that is binding to ViewModel and inside your xaml you have a control that has DataTemplate The code Below we are […]

dotnet C#

In C# there is a params keyword which allows a method parameter to take variable number of arguments. MSDN Some notes on param It must always be the last parameter in the function/method definition There can only be one params keyword in a function/method parameter signature Example:

But by changing it to params we […]

UA-4524639-2