dr_twilight

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

public ActionResult Index()
{
List<RandomData> dataList = new List<RandomData>
{
new RandomData {Id = 1, UserId = 1,RandomDatas = 1,IsSelected = 0, UpToDate= Convert.ToDateTime("2015-7-18 23:59:59")},

new RandomData {Id = 12, UserId = 51,RandomDatas = 3,IsSelected = 0, UpToDate= Convert.ToDateTime("2015-7-15 23:59:59")}

};
dataList = dataList.Where(o => DateTime.Compare(o.UpToDate, Convert.ToDateTime("2015-7-16 23:59:59")) < 0).ToList();
RandomData val = GenerateRandomNumber(dataList);
var query = (from r in dataList
where r.UserId == val.UserId
select r).FirstOrDefault().IsSelected = 1;

return View();
}

public static RandomData GenerateRandomNumber(List<RandomData> dataList)
{
Random rd = new Random();
int i = rd.Next(dataList.Count);
return dataList[i];
}

posted on 2015-07-16 17:46  dr_twilight  阅读(157)  评论(0编辑  收藏  举报