I have a LINQ query that looks like the following:
DateTime today = DateTime.UtcNow;
var results = from order in context.Orders
where ((order.OrderDate <= today) && (today <= order.OrderDate))
select order;
I am trying to learn / understand LINQ. In some cases, I need to add two additional WHERE clauses. In an effort to do this, I'm using:
if (useAdditionalClauses)
{
results = results.Where(o => o.OrderStatus == OrderStatus.Open) // Now I'm stuck.
}
As you can see, I know how to add an additional WHERE clause. But how do I add multiple? For instance, I'd like to add
WHERE o.OrderStatus == OrderStatus.Open AND o.CustomerID == customerID
to my previous query. How do I do this using extension methods?
Thank you!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…