Editorials

Linq Without SQL Engines

I’ve been using Linq a lot lately demonstrating set operations that were exclusively SQL work for me in the past. However, now I am working with a lot of data that does not come from a relational data store, and libraries such as Entity Framework have no impact on my work.

I am gather sets of data from a multitude of different sources, and packaging them up as collections of C# objects. Now, all of the sudden, I want to perform set operations without using my familiar SQL syntax.

It is for this reason I am finding Linq to be of high value. It has a familiar syntax, and performs extremely fast. There are some techniques you must learn about Linq that can impact the performance. For example, if you convert the results of a Linq query into a list (ToList()) or an array (ToArray()) it can highly impact the performance of the consumers.

I’ve even used the equivalent of a Pivot Table in Linq to transform data from a non-pivoted to a pivoted form, and back again. It is quite powerful, and a lot easier to read than a bunch of logic in a for loop.

So, if you open your horizons to sets of data outside of a relational database, not returned from an ORM, is Linq the Set handling framework in Dot Net? Should we be looking to F# instead? Share your comments here, or by Email to btaylor@sswug.org.

Cheers,

Ben