标签:
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];
}
标签:
原文地址:http://www.cnblogs.com/niejun/p/4652030.html