Small optimization of query (#6153)

This commit is contained in:
Nicolas Dorier 2024-08-22 18:52:53 +09:00 committed by GitHub
parent 07f3301e32
commit 6d560caf06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -662,13 +662,27 @@ retry:
if (queryObject.OrderId is { Length: > 0 })
{
var orderIdSet = queryObject.OrderId.ToHashSet().ToArray();
query = query.Where(i => orderIdSet.Contains(i.OrderId));
if (queryObject.OrderId is [var orderId])
{
query = query.Where(i => i.OrderId == orderId);
}
else
{
var orderIdSet = queryObject.OrderId.ToHashSet().ToArray();
query = query.Where(i => orderIdSet.Contains(i.OrderId));
}
}
if (queryObject.ItemCode is { Length: > 0 })
{
var itemCodeSet = queryObject.ItemCode.ToHashSet().ToArray();
query = query.Where(i => itemCodeSet.Contains(i.ItemCode));
if (queryObject.ItemCode is [var itemCode])
{
query = query.Where(i => i.ItemCode == itemCode);
}
else
{
var itemCodeSet = queryObject.ItemCode.ToHashSet().ToArray();
query = query.Where(i => itemCodeSet.Contains(i.ItemCode));
}
}
var statusSet = queryObject.Status is { Length: > 0 }