【发布时间】:2010-05-17 14:49:31
【问题描述】:
我是 LINQ 的新手,所以提前道歉
我有以下 Linq 查询:-
var OrdersByBranches =
from a in AllOrders
join b in AllBranchKeys
on a.BranchKey equals b.BranchKey
orderby a.Date
group a by new { a.Date, a.paymentMethod } into BranchOrderGrouped
select new
{
BranchOrderGrouped.Key.Date,
CurrencyAmount = BranchOrderGrouped.Sum(a =>
a.CurrencyAmount),
BranchOrderGrouped.Key.paymentMethod
};
我需要在上面的查询中包含一个 where 子句......只有当一个变量调用 BranchKeySelected 为 ""
我尝试过使用 If Else 语句,并且将上述相同的查询与 一个包含 where 子句和一个 NOT。 ...但是当我这样做时.. 然后 OrdersByBranches 在 IF 语句之外不可用
如果有任何帮助,将不胜感激
问候
幽灵
【问题讨论】: