Fizz Buzz in LINQ

November 1, 2017

Here's a simple implementation of FizzBuzz using LINQ:

List<string> lResults = new List<string>();
IEnumerable<int> lOneToHundred = Enumerable.Range(1, 100);
lOneToHundred.ToList().ForEach(i => lResults.Add(i % 15 == 0 ? "FizzBuzz" :
                                                         i % 3 == 0 ? "Fizz" :
                                                         i % 5 == 0 ? "Buzz" :

foreach (string lValue in lResults.Take(20))
    Console ...

LINQ Reference

October 31, 2017

The benefits of using the LINQ approach rather than lots of foreach loops are:

  • Composability
  • Lazy Evaluation
  • Immutability
  • Parallelizable
  • Declarative

The functions available in LINQ can be split into four categories:

  • Generator Functions.- create values out of nothing
  • Statistical Functions - find out stats about the data (count, any that match ...

Tags: linq

Confluence Login Errors

September 27, 2017

I have a Confluence deployment that uses Crowd to authenticate users against Active Directory.

One of the users got a System Error at login:

org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2
    at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(
    at org.springframework.orm ...

HTTP Client in Dot Net Core

August 25, 2017

In parallel to the Java/Http Client 4 implementation in the previous post, I also needed to do a call from .NET core in C#.

The endpoint here needs a JSON string posting to it, and it returns JSON back. It's particular about the headers passed - the Content-Type needed ...

HTTP Client 4 and a JSON endpoint

August 17, 2017

I need to POST to a HTTPS JSON based service endpoint in Java. I can do this using Http Client 4.

In the following code, SERVICE_ENDPOINT is the full URL to the service, in my case https://" + SERVICE_HOST + "/v2/. The other values should be self explanatory, and are all strings ...