tags:

views:

32

answers:

1

How can I give specific names to the customers variable's properties, e.g.:

PSEUDO-CODE:

var customers = from c in Customers
    where c.Orders.Count > 15
    orderby c.Orders.Count ascending
    select new { 
     c.ContactName as Name, 
     c.City, 
     c.Orders.Count as NumberOfOrders };
+12  A: 

Like this, using the object initializer syntax:

var customers = from c in Customers
    where c.Orders.Count > 15
    orderby c.Orders.Count ascending
    select new 
    { 
        Name = c.ContactName, 
        c.City, 
        NumberOfOrders = c.Orders.Count
    };
CMS
@CMS you think this is all he wants? +1 for answering exactly what he asked.
KP