How the return type is determined in a method that uses Linq2Sql?
- by Richard77
Hello,
I've usually have difficulties with return types when it comes to linq. I'll explain by the following examples. Let's say I have a Table Products with ProductID, Name, Category, and Price as columns :
1) IQueryable<Product
public IQueryable<Product> GetChildrenProducts()
{
  return (from pd in db.Products
          where pd.Category == "Children"
          select pd);
}
2) Product 
public Product GetProduct(int id)
{
  return (from pd in db.Products
          where pd.ProductID == id
          select pd).FirstOrDefault();
}
Now, if I decide to select, for instance, only one column (Price or Name) or even 2 or 3 columns (Name and Price), but in any case, less than the 4 columns, what's going to be the return type?
I mean this:
public returnType GetSomeInformation()
{
 return (from pd in db.Products
         select new { pd.Name, pd.Price }
}
What SHOULD BE the returnType for the GetSomeInformation()? 
Thanks for helping