新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
詳談Linq查詢結(jié)果分析的方法
很多人還不是很了解Linq查詢結(jié)果,為了解決大家的這個盲區(qū),筆者寫了一篇關于內(nèi)容的文章,當你看完本文一定會收獲很大的。

使用Linq查詢結(jié)果:
如果查詢結(jié)果是強類型的,如string[],List 等,就可以不用var類型,而是使用合適的 IEnumerable 或IEnumerable(因為IEnumerable 也擴展了IEnumerable)類型。
- class Program
- {
- static void Main(string[] args)
- { Console.WriteLine("***** LINQ Transformations *****"n");
- IEnumerable
subset = GetStringSubset(); - foreach (string item in subset)
- {
- Console.WriteLine(item);
- }
- Console.ReadLine();
- }
- static IEnumerable
GetStringSubset() - {
- string[] currentVideoGames = {"Morrowind", "BioShock",
- "Half Life 2: Episode 1", "The Darkness",
- "Daxter", "System Shock 2"};
- // Note subset is an IEnumerable compatible object.
- IEnumerable
subset = from g in currentVideoGames - where g.Length > 6
- orderby g
- select g;
- return subset;
- }
- }
使用Linq查詢結(jié)果的分頁處理:
- var custTotalOrders = from c in db.D_WorkCenter
- //join o in db.Orders
- //on c.CustomerID equals o.CustomerID into custOrders
- //from o in custOrders select new
- {
- WorkCenterID = c.WorkCenterID,
- WorkCenterName = c.WorkCenterName
- //OrderTotal = o.Order_Details.Sum(d => d.UnitPrice * d.Quantity)
- }
以上就是對Linq查詢結(jié)果的簡單分析。
【編輯推薦】
- 簡單解決Linq多條件組合問題
- 將數(shù)據(jù)源進行Linq排序
- Ordering方法實現(xiàn)Linq排序
- 輕輕松松學習Linq排序
- 詳解Linq聯(lián)合查詢表結(jié)果集的返回
網(wǎng)站欄目:詳談Linq查詢結(jié)果分析的方法
當前路徑:http://www.dlmjj.cn/article/dpchogo.html


咨詢
建站咨詢
