我有以下代码
var reportQuery = new Func<IQueryable<Bid>, IEnumerable<ApprovalRequestDashboardVM>>(bids =>
{
return Bid.GetScopeAndPricingDependencies(bids).SelectMany(bid =>
{
var bidWorkflowApprovalValues = bid.ApprovalWorkflows.Values.Where(a => a.StatusHasAlwaysBeenNotEffective == false)
.OrderBy(a => a.Name)
.ThenBy(a => a.Node.NodeType)
.ThenBy(a => a.Node.NodeName);
return bidWorkflowApprovalValues.SelectMany(aw =>
{
return aw.StatusHistory.Where(history => filterApprovalStatus.Count() > 0 ? filterApprovalStatus.Contains(history.StatusID) : true).Select(history =>
{
return new ApprovalRequestDashboardVM()
{
ApprovalID = aw.ApprovalID,
ApprovalName = aw.Name,
BidID = bid.BidID,
BidVersionNumber = bid.BidVersionNumber,
BidStatus = bid.Status,
ApprovalStatus = history.Status,
StatusDate = history.StatusDate,
};
});
});
});
});
我试图根据某些条件过滤出价
public bool AllApprovalWorkflowsApproved()
{
if (this.ApprovalWorkflows.Values.Where(x => x.Status == ApprovalStatus.Reviewing).Count() > 0)
{
return false;
}
else
return true;
}
因此如果我将其添加到查询
bids = bids.Where(x => x.AllApprovalWorkflowsApproved());
要确保仅出价在审查状态时没有工作流的投标,然后我会发现一个错误,即EF无法将我的方法转换为存储表达式。
有人可以告诉我如何过滤selectany中的数据
谢谢
class Program
{
static void Main(string[] args)
{
string[] array =
{
"king",
"queen",
"throne"
};
var result = array.SelectMany(element => element.ToCharArray())
.Where(RemoveLetterTSpec)
.Where(RemoveLetterESpec);
foreach (char letter in result)
{
Console.WriteLine(letter);
}
Console.ReadLine();
}
private static bool RemoveLetterESpec(char arg)
{
return arg != 'e';
}
private static bool RemoveLetterTSpec(char arg)
{
return arg != 't';
}
}
这是一个简单的示例,讲述了如何过滤selectany