我是根据股票交易计算库存但是我想排除那些发票没有标记为 IsStocked 这是Nullable布尔值的股票交易,我试图通过使用 SkipWhile实现这一点哪个无效,无论发票 IsStocked 属性是真还是假,它都只统计所有交易:
以下是我的尝试:
For i = LBound(SheetPosition) To UBound(SheetPosition)
For j = LBound(Position) To UBound(Position)
For k = LBound(Direction) To UBound(Direction)
For l = LBound(Temper) To UBound(Temper)
MsgBox i
MsgBox SheetPosition(i)
MsgBox j
MsgBox Position(j)
MsgBox k
MsgBox Direction(k)
MsgBox l
MsgBox Temper(l)
Next
Next
Next
Next
答案 0 :(得分:1)
您可以尝试 Where 子句。
public double GetInStockQuantity(Warehouse warehouse, Entities db)
{
double res;
try
{
res = db.Stocks.AsNoTracking().Where(c => c.Product.ID == ID && c.WarehouseID == warehouse.ID).
AsNoTracking().AsEnumerable().
Where(c => c.InvoiceItems.Any(q => q.Invoice.IsStocked == true)).Sum(q => q.Quantity);
}
catch (Exception)
{
res = 0;
}
return res;
}