LINQ
Posted 郎喜集团
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LINQ相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章