【发布时间】:2014-01-06 02:10:05
【问题描述】:
我的程序是一个任务程序。我想做的是为用户/员工构建一个 UI,以查看他们在登录当天必须执行的任务。
我在 1-M 中有两张表,PostOne 和 PostEig。
- PostOne 是包含单个任务信息的主表。
- PostEig 是在 Post One 中分配给任务的用户表。
模型[简化]
public class PostOne
{
public string One { get; set; }
[Key]
public string Two { get; set; }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd-MMM-yyyy}", ApplyFormatInEditMode = true)]
public DateTime ThrD { get; set; }
}
public class PostEig
{
public string EigOne { get; set; }
public string EigTwo { get; set; } //foreign key
[Key]
public string EigID { get; set; }
[Required]
public string EigA { get; set; } //user login
}
我遇到了控制器问题。我什至不确定如何开始编写实现目标所需的代码,所以我将尝试将其写出来:
- 调用 PostEigs 列表,其中 EigA == User.Identity.Name
- 并从此列表中......调用 PostOnes 列表,其中两个 == EigTwo
- 并从此列表中......调用 PostOnes 列表,其中 ThrD == DateTime.UtcNow.Date
我确实尝试过这样的事情:
public ActionResult SkedList()
{
return View(db.PostEigs.Where(m =>
m.EigA == User.Identity.Name ||
m.EigTwo == db.PostOnes.Where(o => o.ThrD == DateTime.UtcNow.Date)
).ToList());
}
如果不清楚,请告诉我。我感谢任何建议或解决方案,即使方向不同。
【问题讨论】:
标签: c# linq asp.net-mvc-4 ef-code-first