Load Workflow from XML file in Workflow Foundation

The other day I had to use Windows Workflow Foundation in legacy .NET 3.5. The goal was to address the scenario where the power user may upload valid XML files … in an Enterprise Application for different workflows, In other words to avoid hard coding the workflow activities in C# code. So I had to essentially address 2 objectives :

  1. The workflow should be loaded dynamically on the fly
  2. There might be more than one workflows.

So I came up a simple design where the power user may upload a XML file and may give nick names … basically a mini XML file management. Then Continue reading “Load Workflow from XML file in Workflow Foundation”


If you’re families with Different Types of SQL Joins which are used to query data from more than one tables, LINQ has a JOIN query operator that provide SQL JOIN like behavior (and syntax … depending on which LINQ syntax you prefer Query or Fluent syntax). To drill down LINQ versus SQL join Continue reading “Enumerable.Join”

The short & sweet answer to : Why IQurayable Vs IEnumerble Or, List …

Fact: What happens with IQueryable<T> is different than with sequences. An instance of IQueryable<T> receives an expression tree it can inspect to decide what processing it should perform.

In principle, as soon as we start enumerating the content of object type; say Customers for example, then expression tree it contains gets analyzed, SQL is generated and executed, and the results of the database query are returned as Customers objects.I don’t want to go into detail about how things work here, but Continue reading “The short & sweet answer to : Why IQurayable Vs IEnumerble Or, List …”

Nested Lists ( ‘Jagged List’ )

Just like Jagged Arrays ( ? ) , it is legal to imagine some sort of ‘Jagged List’, or Nested List, which quite similarly lets us come up with multi-dimensional List datastructure hierarchies.

The code below would actually Continue reading “Nested Lists ( ‘Jagged List’ )”

Wanna bind an enum to Combobox / Dropdown ?

Many people prefer to bind an enum to a dropdown in their WinForms application. In the cases where we can not bring the values from backend/database, it makes sense to use enum as opposed to hard-coding values over and over again. Enumerations support a practice where a group of related constants may be created which later be viewed as string or integer values.

Before we see how could this be achieved in Windows Forms Application ( WinForms App ), ASP.NET WebForms, ASP.NET MVC ( even easier in MVC 5 ! ) as well as ASP.NET Web API, let’s talk about : ‘Why ?’

Why using Enum is preferred if combobox is not being flourished from DB ? Well, In addition to re-usability, there are some clear advantages :

Continue reading “Wanna bind an enum to Combobox / Dropdown ?”

C# String Perf Take # 2 ( Accused : IsNullOrEmpty() )

String is a reference type. The IsNullOrEmpty is used to check weather string reference is null (null) or contains any data (empty string). According to MSDN :

Continue reading “C# String Perf Take # 2 ( Accused : IsNullOrEmpty() )”

FAQ : “==” or .Equals() ?

It is I would use the a very simple example used on MSDN Blog post.

Continue reading “FAQ : “==” or .Equals() ?”

Where Extension Method V/s FindAll

Upon checking on MSDN, the only advantage of FindAll I found is backwards compatibility until .NET 2.0 on the other hand, Where seemed to be introduced in .NET 3.5 … Technically, Where should outperform FindAll for large number of records as despite the observations that on small set, these two would likely perform comparably. The reason is their mechanisms.

FindAll copies the matching elements to a new list, whereas Where just returns a lazily evaluated sequence – no copying is required. That said in the case of “FindAll”, the new List created to contain the results will have to dynamically grow to contain additional results. Memory usage of FindAll will also start to grow exponentially as the number of matching results increases where as … “Where” should have constant minimal memory usage.

Ref : http://stackoverflow.com/a/2260227, http://stackoverflow.com/a/1531756