Yield Return Dangerously Delicious

I´m a big fan of neat constructs such as the yield return in C#. The yield return allows you to return results from a method line by line instead of summing it up in a list or such. You can see the difference between these two methods: public IEnumerable<string>...

Comparing exact datetimes in entity framework

Seems there´s still some issues you have to struggle with in Entity Framework even though the latest releases have made it actually possible to work with. This time I got a problem whilst trying to retreive av bunch of items logged with the same timestamp. Entity...

Entity Framework query sql

Ever tried to build complex joins using Linq with Entity Framework and finally ending up with something you just suspect might be a hell of a lot less efficient than possible? In that moment it might prove useful to get the clean actual SQL your Linq query actually...

Check if enumerable is empty?

Quite often I find myself wanting to check in a petite way if an enumerable is empty. Instead of having to do: bool notEmpty = myEnumerable.GetEnumerator().MoveNext(); Using linq you can simply use this System.Linq.Any() extension method: var notEmpty =...

Stumbling in Linq

Ever faced any of these questions? My enumeration is empty!?Where did my items go?Why do Linq remove things I don’t want removed?Where´s the items in my Where?! I just did. Linq is a nice little feature but when using enumerations you really need to keep your...