lamda表达式 随机取数据的方法

随机取数据,关键要用到Guid.NewGuid()才可以的,Take(10)表示随机取10条记录

var _icpics = DB.I_FirstRecommend.GetAllList().Where(s => !string.IsNullOrEmpty(s.Scenery)).OrderBy(s => Guid.NewGuid()).Take(10).ToList();//随机只取1图片就可以了

posted on 2016-04-21 16:12  波澜不惊super  阅读(835)  评论(0编辑  收藏  举报

导航