Simple Examples of joining 2 and 3 table using lambda expression

前端 未结 3 1496
情书的邮戳
情书的邮戳 2020-12-25 11:34

Can anyone show me two simple examples of joining 2 and 3 tables using LAMBDA EXPRESSION(
for example using Northwind tables (Orders,CustomerID,EmployeeID)

3条回答
  •  梦毁少年i
    2020-12-25 12:06

    public void Linq102() 
    { 
    
    string[] categories = new string[]{  
        "Beverages",   
        "Condiments",   
        "Vegetables",   
        "Dairy Products",   
        "Seafood" };  
    
    List products = GetProductList(); 
    
    var q = 
        from c in categories 
        join p in products on c equals p.Category 
        select new { Category = c, p.ProductName }; 
    
    foreach (var v in q) 
    { 
        Console.WriteLine(v.ProductName + ": " + v.Category);  
    } 
    }
    

提交回复
热议问题