日期:2014-05-20  浏览次数:20938 次

LINQ 方法参数看不懂
怎么我在编译器写代码LINQ方法参数提示看不懂啊,比如 GroupBy(Of TSource, TKey)(IQueryable(Of TSource), Expression(Of Func(Of TSource, TKey)))之类的,我都不知道到该传入什么参数?还有我想问下LINQ怎么左连接然后对数据读取?

------解决方案--------------------
left join:
C# code

public void Linq105()  
{ 
    string[] categories = new string[]{   
        "Beverages",  
        "Condiments",   
        "Vegetables",   
        "Dairy Products",  
        "Seafood" }; 
  
    List<Product> products = GetProductList(); 
  
  
  
    var q = 
        from c in categories 
        join p in products on c equals p.Category into ps 
        from p in ps.DefaultIfEmpty() 
        select new { Category = c, ProductName = p == null ? "(No products)" : p.ProductName }; 
  
    foreach (var v in q) 
    { 
        Console.WriteLine(v.ProductName + ": " + v.Category); 
    } 
}

------解决方案--------------------
Group by
http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b