Blog Home  Home RSS 2.0    
Arnon Rotem-Gal-Oz's Cirrus Minor - Back to the future with LINQ
Archive
 
 Wednesday, September 14, 2005

(like everyone else ?) I've finished reading the C#3 Spec and the LINQ project overview.

with samples like:

public void Linq43() {
   List customers = GetCustomerList();


   var customerOrderGroups = 
         from c in customers
            select
               new {c.CompanyName, 
                  YearGroups =
                     from o in c.Orders
                        group o by o.OrderDate.Year into yg
                        select
                           new {Year = yg.Key,
                              MonthGroups = 
                                 from o in yg.Group
                                 group o by o.OrderDate.Month into mg
                                 select new {Month = mg.Key, Orders = mg.Group}
                                }
                    };

ObjectDumper.Write(customerOrderGroups, 3);
}

Hey - that's de ja vous all over again :)

Actually it is (er..will be) much stronger than SQL - for one, you can use a single LINQ query to combine data from arrays and data and XML and whatever. Also combined with lambda expressions (next gen for anonymous methods ) you'd have even more power.

While I am on the subject of what's new in C# 3.0 - I also found Extension methods very interesting - it kind of lets you have a look and feel of multiple inheritance without the associated headaches

consider the following

namespace MultipleInheritanceSimulation
{
   public static class Extensions 
   {
      public static void DoSomething<T>(this T var) 
      {
         //do whatever
      }

   }
}

And then:

using MultipleInheritanceSimulation;

namespace Tester
{
   public class Foo
   {
      public void Bar()
      {
         MyClass x;
         MyOtherClass y;
   
         x.DoSomething();
         y.DoSomething();
      }
   }
}

 

oh well,enough playing - back to work...


9/14/2005 11:17:52 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [0]   .NET | Everything  | 
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Copyright © 2013 Arnon Rotem-Gal-Oz. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: