How can I convert this query to use Extension Methods?
var x = from Prods 开发者_如何学JAVAn in Cat.Prod.GetAllProds()
        orderby n.Name
        select new
        {
            Name = n.Name,                        
            Cost = n.Cost
        };
Its called Lambda notation.
var x = Cat.Prod.GetAllProds().OrderBy(n=>n.Name).Select(n=>new {n.Name,n.Cost});
Note that you do not need to provide a name for each column you are selecting if that name is the same as the column name:
new
{
    Name = n.Name,                        
    Cost = n.Cost
});
Is exactly the same as:
new
{
    n.Name,                        
    n.Cost
});
It's quite simple in this case:
var x = Cat.Prod
           .GetAllProds()
           .OrderBy(n => n.Name)
           .Select(n => new
                        {
                           Name = n.Name,                        
                           Cost = n.Cost
                        });
For more information, I suggest reading How query expressions work - Jon Skeet: Coding Blog.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论