Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 需要从datatable检索当前空缺_Sql Server_Asp.net Mvc_Linq_Asp.net Mvc 4 - Fatal编程技术网

Sql server 需要从datatable检索当前空缺

Sql server 需要从datatable检索当前空缺,sql-server,asp.net-mvc,linq,asp.net-mvc-4,Sql Server,Asp.net Mvc,Linq,Asp.net Mvc 4,我需要检索申请日期大于或等于今天的空缺。 但此查询检索所有空缺。您并不是在筛选您的工作集合,只是对它们进行排序 var today = DateTime.Today; DateTime tday = Convert.ToDateTime(today); return View(db.job.OrderBy(x => x.dateApplyBy >= tday).ToList()); 您知道这是毫无意义的:Convert.ToDateTime(DateTime.Today)?如果您

我需要检索申请日期大于或等于今天的空缺。
但此查询检索所有空缺。

您并不是在筛选您的工作集合,只是对它们进行排序

var today = DateTime.Today;

DateTime tday = Convert.ToDateTime(today);
return View(db.job.OrderBy(x => x.dateApplyBy >= tday).ToList());

您知道这是毫无意义的:
Convert.ToDateTime(DateTime.Today)
?如果您已经有一个
DateTime
,则不需要将其转换为一个。什么地方有?orderby进行排序。排序后,您需要应用
where
top
(限制)。@Muhammadfarhan:-如果这对您有效,您可以接受答案(单击时右勾号变为绿色)
return View(db.job.Where(j => j.dateApplyBy >= DateTime.Today).ToList());
var today = DateTime.Today;

DateTime tday = Convert.ToDateTime(today);
return View(db.job.Where(x = xdateApply >= today).OrderBy(x => x.dateApplyBy).ToList());