码迷,mamicode.com
首页 > 其他好文 > 详细

LINQ

时间:2016-03-15 00:31:46      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:

string [] cities={"London","Amsterdam","San Fran","a"};

GridView1.DataSource=from city in cites where city.length>4 orderby city select city.ToUpper();

 

返回类型:IEnumerable<string> result =from city in cities where city.Length>4 orderby city select ctiy.ToUpper();

select 子句选择的对象类型决定了这里的<T>类型。、

ASP.net 控件可以绑定到任何的IEnumerable 集合。如:<asp:Repeater>,<asp:datalist>

<asp:dropdownlist>

List<Location> cities =new List<Location>{new Location{City,"Londoen",Country="England",Distance=12},{City,"Londddoen",Country="England",Distance=122}};

GridView1.DataSource=from location in cities where location.Diatance>12 orderby

location.country,location.City select location;

GridView1.DataBind();

 

LINQ

标签:

原文地址:http://www.cnblogs.com/zhubenxi/p/5277669.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!