linq之into子句
2016-04-20 16:40
309 查看
在Linq表达式中,into子句可以创建一个临时标识符,使用该标识符可以存储group、join或select子句的结果。
下面实例中我们用GroupOtherQuery方法来演示group子句对结果集进行分组。
一般group子句不需要into子句,除非对每一个分组进行操作。
运行结果如下:
下面实例中我们用GroupOtherQuery方法来演示group子句对结果集进行分组。
private void GroupOtherQuery() { List<UserBaseInfo> users = new List<UserBaseInfo>(); for(int i=1;i<10;i++) { users.Add(new UserBaseInfo(i,"users0"+i.ToString(),"user0"+i.ToString()+"@web.com")); } var result = from u in users group u by Int32.Parse(u.UserName.Substring(u.UserName.Length - 2)) % 2 == 0 into g where g.Count() < 5 select g; foreach (var v in result) { foreach (UserBaseInfo u in v) { Response.Write(u.UserName + "</br>"); } } }
一般group子句不需要into子句,除非对每一个分组进行操作。
运行结果如下:
相关文章推荐
- mysql tee 命令
- 用Drawable来实现UI元素的间隔
- static方法可以被重写(覆盖)吗?
- 解开Bind zone文件自动改变之迷
- R.NET用于Excel Add-In的多实例(multi-Instance)问题及解决方法(1)
- 把数组排成最小的数
- HTML DOM 方法
- 51nod多重背包问题
- Maven依赖范围scope
- no lable views point to this text field with an android:lablFor=”@+id/@+id
- android警告——Buttons in button bars should be border
- vector 用法
- git 整理
- 副业?副业才有趣,才精彩
- 我所知道的几种display:table-cell的应用
- kinect 接触的一篇初级文章
- C++ 指针
- activeMQ networkConnectors
- NSDate计算两个时间日期的时差
- ScrollView中软键盘弹出依然遮住控件