我有以下LINQ查詢where子句不返回預期結果。 dtTemp row.Item(0)
具有類似於"GE", "LE", "ST", "PL"
的值,而Stkyard
是具有一個或多個這些值的字符串數組。Linq查詢字符串數組where條款
我期待下面的查詢來Stkyard
篩選基於項值,但返回的結果集在dtTemp
dtQuery = (From row In dtTemp
Group row By grp =
New With {Key .mth = row.Item(1), Key .mthdesc = row.Item(2)} Into Group,
val1 = Sum(Convert.ToDecimal(row.Item(3))), val2 = Sum(Convert.ToDecimal(row.Item(4)))
Where Group.Any(Function(p) Stkyard.Contains(p.Item(0)))
Select New With {grp.mth, grp.mthdesc, val1, val2}
Distinct).ToList
任何幫助所有值的總和?
DonNetFiddle Example
你能分享[.NETFiddle(https://dotnetfiddle.net/)的例子嗎? – aloisdg
@aloisdg我在帖子中添加了一個示例。 – Nilanjan