So I have a function like below which takes in a list of objects and keeps including them into my query string. This works great.
query = includeExpressions.Aggregate(query, (current, include) => current.Include(include));
But what I am wanting to do is to Aggregate the OrderBys as well. This is where I am running into issues. The issue I have is that one must use OrderBy then use ThenBy on the same line. I've tried using a for loop first item use order by then on use thenby. The issue I am running in is that in order for thenby to be activated the order by needs to proceed it on the same object line.
query.OrderBy(orderBy).ThenBy
I can not do
var usedOrderBy = true;
foreach (var orderBy in orderBys)
{
if (usedOrderBy)
{
query = query.OrderBy(orderBy);
usedOrderBy = true;
}
else
{
query = query.ThenBy(orderBy); // <-- Can not locate thenby
}
}
any ides.
I want to pass in like
orderItems(x => x.Item1, x => x.Item2)