【发布时间】:2021-10-05 23:39:21
【问题描述】:
我有以下 EF 代码头等舱来跟踪该人在机场的到达状态。在每次检查中,记录都会插入到这个表中。以下是演示流程的步骤。
Landed -> FirstCheck Approved -> Clearance Approved -> Arrived
Landed -> FirstCheck Approved -> Clearance Approved -> Security Check -> Denied // This is the one I need to query
Landed -> FirstCheck Approved -> Clearance Approved -> Security Check -> Arrived
我需要找到 FirstCheck Approved 和 SecurityCheck 的被拒绝记录来跟踪原因。
public class ArrivalStatusLog
{
public ArrivalStatusLog();
public int ArrivalStatusLogId { get; set; }
public int PersonNumber{ get; set; }
public DateTime CreationDate { get; set; }
public string Status { get; set; }
}
EF 查询
var denialPersons = await db.ArrivalStatusLogs
.Where(s => s.Status == "Denied") // Additional filter
.Select(x => x.PersonNumber)
对于具有其他状态的给定人员,如何对同一表中的其他记录执行 AND 条件?在我的情况下,我需要找到 Denied,然后是 FirstCheck Approved 和 Security Check。
【问题讨论】:
-
如果同一个人多次旅行、过去被完全接受、后来被拒绝,您将如何检测?还是过去被拒绝,后来又接受了?
标签: c# sql-server entity-framework linq entity-framework-6