自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

詳談Linq查詢結果分析的方法

開發(fā) 后端
很多人還不是很了解Linq查詢結果,為了解決大家的這個盲區(qū),筆者寫了一篇關于內容的文章,當你看完本文一定會收獲很大的。

很多人還不是很了解Linq查詢結果,為了解決大家的這個盲區(qū),筆者寫了一篇關于內容的文章,當你看完本文一定會收獲很大的。

使用Linq查詢結果:

如果查詢結果是強類型的,如string[],List等,就可以不用var類型,而是使用合適的 IEnumerable或IEnumerable(因為IEnumerable也擴展了IEnumerable)類型。

  1. class Program   
  2. {    
  3. static void Main(string[] args)   
  4. {  Console.WriteLine("***** LINQ Transformations *****"n");   
  5. IEnumerable<string> subset = GetStringSubset();    
  6. foreach (string item in subset)    
  7. {   
  8. Console.WriteLine(item);    
  9. }    
  10. Console.ReadLine();    
  11. }  
  12. static IEnumerable<string> GetStringSubset()   
  13. {    
  14. string[] currentVideoGames = {"Morrowind""BioShock",    
  15. "Half Life 2: Episode 1""The Darkness",    
  16. "Daxter""System Shock 2"};    
  17. // Note subset is an IEnumerable compatible object.   
  18. IEnumerable<string> subset = from g in currentVideoGames    
  19. where g.Length > 6   
  20. orderby g    
  21. select g;    
  22. return subset;    
  23. }  
  24. }  

使用Linq查詢結果的分頁處理:

  1. var custTotalOrders = from c in db.D_WorkCenter    
  2. //join o in db.Orders    
  3. //on c.CustomerID equals o.CustomerID into custOrders    
  4. //from o in custOrders  select new    
  5. {    
  6. WorkCenterID = c.WorkCenterID,    
  7. WorkCenterName = c.WorkCenterName    
  8. //OrderTotal = o.Order_Details.Sum(d => d.UnitPrice * d.Quantity)   
  9. }  

以上就是對Linq查詢結果的簡單分析。

【編輯推薦】

  1. 簡單解決Linq多條件組合問題
  2. 將數據源進行Linq排序
  3. Ordering方法實現Linq排序
  4. 輕輕松松學習Linq排序
  5. 詳解Linq聯合查詢表結果集的返回
責任編輯:阡陌 來源: 新客網
相關推薦

2009-09-14 10:09:26

LINQ查詢結果

2009-09-14 18:53:27

LINQ查詢

2009-09-15 10:46:04

LINQ to SQL

2009-09-17 17:03:13

LINQ動態(tài)查詢

2009-09-15 14:58:26

Linq查詢本質

2009-09-16 10:48:32

LINQ查詢操作

2009-09-16 15:41:45

LINQ查詢XML文檔

2009-09-18 16:46:15

LINQ查詢句法

2009-09-15 15:45:00

Linq聯合查詢

2023-10-27 11:15:18

內存query打印

2009-09-17 11:29:50

Linq擴展方法

2009-09-14 17:03:32

LINQ模糊查詢

2009-09-13 21:52:16

LINQ字符串

2009-08-27 13:10:54

LINQ from子句

2009-09-09 10:58:58

Linq結果集形狀

2009-09-09 11:14:04

Linq多個結果集

2009-09-14 18:41:59

LINQ查詢

2009-09-14 19:14:51

LINQ動態(tài)查詢

2009-09-09 16:53:53

LINQ查詢語法

2009-09-14 10:13:02

LINQ查詢操作
點贊
收藏

51CTO技術棧公眾號