.NET 4.5 Async “ConfigureAwait” – Keep the Synchronization Context in Mind

Saturday, December 1, 2012

I assume you have heard about the great addition in .NET 4.5 – The Async Keyword. It is truly one of the key changes made to the .NET language, and it is awesome. Asynchrony should be part of our code, there’s no escape from that. If you write UI applications – you need asynchrony to avoid blocking the UI thread. If you make I/O operations – you should use its asynchronous model that utilizes the I/O completion threads instead of occupying a worker thread. ...
tags: ,
one comment

Localize DayOfWeek Enum

Tuesday, October 12, 2010

If you have a DateTime and you would like to get the localized name of the day according to the current culture, you can just do the following - myDateTime.ToString(“ddd”); I had a different scenario though, I had an object with a property of DayOfWeek enum which represents week days. I needed to display just that property in my UI as a localized string. In this case, I don’t have a DateTime so I can’t use its culture-based string formatting, so I can’t use the approach written above. ...
tags: ,
2 comments

Entity Designer Database Generation Power Pack

Wednesday, February 10, 2010

Via Entity Designer Database Generation Power Pack A power pack for Model-First design approach in Entity Framework for Visual Studio 2010. It builds on the new EF4 extensibility points (WF & T4) and provides the following: Basic Table-per-Hierarchy support. This is represented by the “Generate T-SQL via T4 (TPH)” workflow. The SSDL and MSL generation pieces can now be tweaked through T4 templates, both in TPH and TPT strategies through the “Generate T-SQL via T4 (TPT)” and “Generate T-SQL via T4 (TPH)” workflows....
tags: ,
no comments

LINQ to SQL – IsNull and Ordering

Saturday, January 30, 2010

I thought I would share a nice small tweak I made to a LINQ to SQL model. Assume I have the following table structure for ‘Categories’: I faced with the need to select categories while ordering it by the combination of Description1 and Description2 (Note: nullable fields). I entered some dummy data to the table to illustrate the point:   The goal is to retrieve the order as follows: 1, 3, 5, 2, 4 After explaining that, lets forward to the LINQ statements then. Take 1...
tags: , ,
4 comments

Comparing NHibernate and EF 4

Thursday, January 21, 2010

Entity Framework has made great progress towards being a popular ORM framework. EF 4 is much more practical and usable version than its previous one. There’s a nice post which debates about the comparison between NHibernate and EF4: Debate: Comparing NHibernate and EF 4 “The general consensus appeared to be that NHibernate has a number of features which are missing from Entity Framework 4.0 like read/write batching, "extra" laziness, collection filters, tweaking, and others, however Entity Framework has a better LINQ provider, documentation and it is supported by Microsoft”
tags: ,
no comments

WCF 4 – Routing Service, The Beginning

Tuesday, January 19, 2010

I have decided I had enough time to “rest” while being swamped with work and personal agenda over the last few months, it’s time to get back on the saddle. I mentioned it some time ago, but one of the core projects I have been working on is building a smart router facade, a sort of a message broker, providing versioning, virtualization, PEP and so on. WCF 4 introduces us with a nicely wrapped router service OOTB. I was on my way to try to determine if I can use that service as the base implementation...
tags: , ,
one comment

Resolve an Assembly’s Public Key

Thursday, October 29, 2009

It happens occasionly that I need to extract an assembly's public key. (Usually when I want to use the InternalsVisibleTo assembly attribute) I find myself constantly searching the web because I keep forgetting :)I decided to post it here in my blog for future reference: sn -Tp <assembly DLL name>
tags: ,
no comments

How to determine if a console window exists for the current process

Friday, October 2, 2009

If you need to determine whether there's a console window for the current process, you can do it as follows:                  private static extern IntPtr GetConsoleWindow();          internal static bool HasConsoleWindow()         {             return GetConsoleWindow() != IntPtr.Zero;         }
tags: ,
no comments

LINQ to Objects – Enumerable.ToList and similiars optimization

Wednesday, February 4, 2009

Update: The post was lost by accident, I added it again. I’ve used the reflector a couple of times to check whether the Enumerable class which provide all the IEnumerable extensions utilizes things taking the actual type into mind. Let’s examine the extension method “Count” - I liked what they did here. They first try and cast it to ICollection, if it passed they simply return the count property. Otherwise they would do what you would do – iterate over the collection and return the iteration counter. I was thrilled to see that...
tags: ,
one comment