日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
Linq.NET查詢操作淺析

本文向大家介紹Linq .NET查詢操作,可能好多人還不了解Linq .NET查詢操作,沒(méi)有關(guān)系,看完本文你肯定有不少收獲,希望本文能教會(huì)你更多東西。

成都創(chuàng)新互聯(lián)公司長(zhǎng)期為千余家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開(kāi)放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為威信企業(yè)提供專業(yè)的做網(wǎng)站、成都網(wǎng)站建設(shè),威信網(wǎng)站改版等技術(shù)服務(wù)。擁有10年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開(kāi)發(fā)。

Linq .NET查詢操作

除了可以返回?cái)?shù)據(jù)集之外,我們可以使用Linq .NET查詢操作來(lái)返回單個(gè)或者統(tǒng)計(jì)數(shù)據(jù)結(jié)果。下面的例子演示了怎么做:

 
 
 
  1. <%@ Page Language="C#" CodeFile="Step5.aspx.cs" Inherits="Step5" %> 
  2.    
  3.  
  4.  
  5.  id="form1" runat="server"> 
  6.  
  7. Aggregate Value Samples

     
  8.    
  9.  
  10. Farthest Distance City: 
  11.  ID="MaxCityNameTxt" runat="server" Text="Label"> 
  12.  ID="MaxCityDistanceTxt" runat="server" Text="Label"> 
 
  •    
  •  
  • Total Travel Distance (outside of US): 
  •  ID="TotalDistanceTxt" runat="server" Text="Label"> 
  •    
  •    
  •  
  • Average Distance: 
  •  ID="AverageDistanceTxt" runat="server" Text="Label"> 
  •    
  •    
  •  
  •  
  •  
  •  
  • Step5.aspx.cs后臺(tái)代碼文件:

     
     
     
    1. using System;  
    2. using System.Collections.Generic;  
    3. using System.Web.UI;  
    4. using System.Query;  
    5.    
    6. public partial class Step5 : System.Web.UI.Page  
    7. {  
    8. protected void Page_Load(object sender, EventArgs e)  
    9. {  
    10. TravelOrganizer travel = new TravelOrganizer();  
    11.  
    12. // Calculate farthest city away  
    13.  
    14. Location farthestCity = (from location in travel.PlacesVisited  
    15. & nbsp; & nbsp; orderby location.Distance descending  
    16. & nbsp; & nbsp; select location).First();  
    17.    
    18. MaxCityNameTxt.Text = farthestCity.City;  
    19. MaxCityDistanceTxt.Text = "(" + farthestCity.Distance + " miles)";  
    20.  
    21. // Calculate total city distances of all cities outside US  
    22.    
    23. int totalDistance = (from location in travel.PlacesVisited  
    24. & nbsp; where location.Country != "USA"  
    25. & nbsp; select location).Sum(loc => loc.Distance);  
    26.    
    27. TotalDistanceTxt.Text = totalDistance + " miles";  
    28.  
    29. // Calculate average city distances of each city trip  
    30.    
    31. double averageDistance = travel.PlacesVisited.Average(loc => loc.Distance);  
    32.    
    33. AverageDistanceTxt.Text = averageDistance + " miles";  
    34. }  

    注意,上面最后兩個(gè)例子使用了新的Lambda表達(dá)式(Lambda Expression)支持-這些表達(dá)式允許我們通過(guò)譬如象委托這樣的代碼段在數(shù)據(jù)之上做進(jìn)一步的操作,從而計(jì)算出一個(gè)結(jié)果來(lái)。你也可以用之來(lái)建立你自己的Linq .NET查詢操作(例如:你可以建立一些特定領(lǐng)域的查詢來(lái)計(jì)算運(yùn)費(fèi)或者收入稅)。所有的對(duì)象都是強(qiáng)類型的,而且支 持智能感知和編譯時(shí)檢查。


    網(wǎng)站題目:Linq.NET查詢操作淺析
    網(wǎng)頁(yè)網(wǎng)址:http://www.5511xx.com/article/ccojsjj.html