伙计们其实我想做这样的查询:
var firstTakeIssues = _db.Query<Issue>().OrderByDescending(i => i.CreatedDate)
.Take(take)
.Having(i => i.Project.ProjectID in IEnumerable<int>)
.Select(i => new {
IssueId = i.IssueID,
State = (StateEnum)i.State,
ProjectName = i.Project.Name,
Priority = (PriorityEnum)i.Priority,
CreatedAt = i.CreatedDate,
PostedBy = i.Client.Name
}).ToList();
我知道这不行,但我想做的是:
我真正想要指出的是,我不知道如何使用having子句进行查询。
答案 0 :(得分:0)
要模仿您的“拥有”条款,我相信您应该能够使用Where
以及Contains
:
var projectIds = new int[] { 1, 2, 4, 6 };
var firstTakeIssues = _db.Query<Issue>()
.OrderByDescending(i => i.CreatedDate)
.Take(take)
.Where(i => projectIds.Contains(i.Project.ProjectID))
.Select(i => new {
IssueId = i.IssueID,
State = (StateEnum)i.State,
ProjectName = i.Project.Name,
Priority = (PriorityEnum)i.Priority,
CreatedAt = i.CreatedDate,
PostedBy = i.Client.Name
}).ToList();