【问题标题】:Need to retrieve current vacancies from datatable需要从数据表中检索当前职位空缺
【发布时间】:2016-05-29 05:54:59
【问题描述】:
var today = DateTime.Today;

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

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

【问题讨论】:

  • 你知道这是没有意义的:Convert.ToDateTime(DateTime.Today)?如果您已经拥有DateTime,则无需将其转换为一个。 DataTable 到底在哪里?
  • orderby 进行排序。您需要在排序后申请wheretop(限制)。

标签: sql-server asp.net-mvc linq asp.net-mvc-4


【解决方案1】:

您没有过滤您的工作集合,只是对它们进行排序。

return View(db.job.Where(j => j.dateApplyBy >= DateTime.Today).ToList());

【讨论】:

  • @Muhammadfarhan:- 如果对你有用,你可以接受答案(点击右勾号符号变为绿色
【解决方案2】:
var today = DateTime.Today;

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

【讨论】:

    猜你喜欢
    • 2014-04-07
    • 2014-04-16
    • 2020-12-13
    • 2017-02-08
    • 1970-01-01
    • 2019-05-03
    • 1970-01-01
    • 2019-03-13
    • 1970-01-01
    相关资源
    最近更新 更多