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

LINQ查詢結果分析

開發(fā) 后端
這里介紹LINQ查詢結果,如果查詢結果是強類型的,如string[],List<T>等,就可以不用var類型,而是使用合適的 IEnumerable<T>或IEnumerable(因為IEnumerable<T>也擴展了IEnumerable)類型。

本文向大家介紹LINQ查詢結果,可能好多人還不了解LINQ查詢結果,沒有關系,看完本文你肯定有不少收獲,希望本文能教會你更多東西。

使用LINQ查詢結果

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

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

【編輯推薦】

  1. Linq to SQL學習經(jīng)驗
  2. Linq隱式類型化局部變量
  3. Linq匿名類型簡單概述
  4. Linq Lambda表達式剖析
  5. Linq對象初始值淺談
責任編輯:佚名 來源: IT168
相關推薦

2009-09-17 08:47:00

Linq查詢

2009-09-15 10:46:04

LINQ to SQL

2009-09-16 10:48:32

LINQ查詢操作

2009-09-14 18:53:27

LINQ查詢

2009-09-16 15:41:45

LINQ查詢XML文檔

2009-09-18 16:46:15

LINQ查詢句法

2009-09-15 14:58:26

Linq查詢本質

2009-09-14 17:03:32

LINQ模糊查詢

2009-09-17 17:03:13

LINQ動態(tài)查詢

2009-09-15 15:45:00

Linq聯(lián)合查詢

2023-10-27 11:15:18

內存query打印

2009-09-09 10:58:58

Linq結果集形狀

2009-09-09 11:14:04

Linq多個結果集

2009-09-17 13:15:20

LINQ查詢

2009-09-16 10:38:43

LINQ查詢

2009-09-16 10:08:06

LINQ查詢

2009-09-09 16:53:53

LINQ查詢語法

2009-09-14 10:13:02

LINQ查詢操作

2009-09-10 16:28:17

LINQ查詢

2009-09-08 17:27:18

LINQ to Dat
點贊
收藏

51CTO技術棧公眾號