tags:

views:

35

answers:

2

I have the following query

 var xyz = from a in prod.Categories
                           where a.CatName.EndsWith("A")
                           select a;

However all the columns are returned in this case. How do i rewrite query so that only few columns are returned like a.CatName, a.CatID, a.CatQty and so on.

+3  A: 
 var xyz = from a in prod.Categories
                           where a.CatName.EndsWith("A")
                           select new { a.CatID,a.CatQty } ;
Julian de Wit
+3  A: 
var xyz = from a in prod.Categories
                           where a.CatName.EndsWith("A")
                           select new { CatName=a.CatName, CatID=a.CatID, CatQty = a.CatQty};
Ben Robinson