Paulo Morgado

.NET Development & Architecture

Recent Articles

view all



Recent Readers

Visitor Locations

Visitor Locations


The opinions and viewpoints expressed in this site are mine and do not necessarily reflect those of Microsoft, my employer or any community that I belong to. Any code or opinions are offered as is. Products or services mentioned are purchased by me, made available to me by my employer or the manufacturer/vendor which doesn't influence my opinion in any way.

More On Another Way For Using The “using” Keyword

In the past I presented another possible use for the using keyword: as hints on LINQ.

I’ve been giving some thought about this lately and refined my proposal.

var q = from person in personCollection using MyEnumerableExtensions
        group person by person.LastName into g using new MyOtherComparer()
        orderby g.Key using new MyComparer()
        select person;

The above query would be converted to:

var q = MyEnumerableExtensions.OrderBy<string, Person>(
    MyEnumerableExtensions.GroupBy<string, Person>(
        person => person.LastName,
        new MyComparer(),
    g => g.Key,
    mew MyOtherComparer()

What do you think of this?


Dave said:

I think Linq is ugly no matter how you slice it.

# August 11, 2008 11:41 AM

Paulo Morgado said:

Hi Dave. Would you care to elaborate on that?

# August 11, 2008 6:26 PM said:

More on another way for using the using keyword.. OMG! :)

# May 26, 2011 1:02 PM