首页 > 其他 > 详细

LINQ

时间:2016-03-15 00:29:54      阅读:168      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!