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

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網營銷解決方案
LinqCity集合描述

稍微重構一下Linq City集合

創(chuàng)新互聯(lián)公司主要從事網頁設計、PC網站建設(電腦版網站建設)、wap網站建設(手機版網站建設)、響應式網站設計、程序開發(fā)、網站優(yōu)化、微網站、微信平臺小程序開發(fā)等,憑借多年來在互聯(lián)網的打拼,我們在互聯(lián)網網站建設行業(yè)積累了豐富的網站建設、網站制作、網站設計、網絡營銷經驗,集策劃、開發(fā)、設計、營銷、管理等多方位專業(yè)化運作于一體。

因為我們將在好幾個示例中重用這個Linq City集合,我決定把它封裝到一個"TravelOrganizer"類中,如下所示:

 
 
 
  1. using System;  
  2. using System.Collections.Generic;   
  3. public class TravelOrganizer  
  4. {  
  5. public List PlacesVisited  
  6. {  
  7. get  
  8. {  
  9. List cities = new List{  
  10. & nbsp; & nbsp;new Location { City="London", Distance=4789, Country="UK" },  
  11. & nbsp; & nbsp;new Location { City="Amsterdam", Distance=4869, Country="Netherlands" },  
  12. & nbsp; & nbsp;new Location { City="San Francisco", Distance=684, Country="USA" },  
  13. & nbsp; & nbsp;new Location { City="Las Vegas", Distance=872, Country="USA" },  
  14. & nbsp; & nbsp;new Location { City="Boston", Distance=2488, Country="USA" },  
  15. & nbsp; & nbsp;new Location { City="Raleigh", Distance=2363, Country="USA" },  
  16. & nbsp; & nbsp;new Location { City="Chicago", Distance=1733, Country="USA" },  
  17. & nbsp; & nbsp;new Location { City="Charleston", Distance=2421, Country="USA" },  
  18. & nbsp; & nbsp;new Location { City="Helsinki", Distance=4771, Country="Finland" },  
  19. & nbsp;new Location { City="Nice", Distance=5428, Country="France" },  
  20. & nbsp; & nbsp;new Location { City="Dublin", Distance=4527, Country="Ireland" }  
  21. & nbsp; & nbsp;};  
  22.    
  23. return cities;  
  24. }  
  25. }  

這使我只需要編寫如下的代碼就能得到跟上面同樣的結果:

 
 
 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Web;  
  4. using System.Web.UI;  
  5. using System.Query;  
  6.    
  7. public partial class Step3 : System.Web.UI.Page  
  8. {  
  9. protected void Page_Load(object sender, EventArgs e)  
  10. {  
  11. TravelOrganizer travel = new TravelOrganizer();  
  12.    
  13. GridView1.DataSource = from location in travel.PlacesVisited  
  14. & nbsp; where location.Distance > 1000  
  15. & nbsp; orderby location.Country, location.City  
  16. & nbsp; select location;  
  17.    
  18. GridView1.DataBind();  
  19. }  

LINQ很酷之處就是它是強類型的。這意味著:

1) 你的所有的查詢都會進行編譯時檢查。不像現(xiàn)在的SQL語句,你只有到運行時才會發(fā)現(xiàn)你的錯誤所 在。這意味著你在開發(fā)時就可以檢查你的代碼的正確性,例如,如果我把上面的"distance"誤寫成 了"distanse",編譯器將為我捕獲到這個錯誤。

2) 當你寫LINQ查詢的時候你將在VS或免費的Visual Web Developer中獲得智能感知的提示。這不僅加 快了編碼的輸入速度,而且使我們在處理無論簡單還是復雜的集合和數(shù)據(jù)源對象模型時都變得非常容易。以上介紹Linq City集合


當前標題:LinqCity集合描述
網站網址:http://www.5511xx.com/article/cddcgde.html