【发布时间】:2021-06-04 16:37:54
【问题描述】:
如何为这种类型的 LINQ 查询(Lambda 表达式)编写 Strng.Join? (var b 将返回整数列表的数量)
1.
var b = braughtForwardInvoices
.Where(x => x.LinkedTransaction != null
&& x.LinkedTransaction.Count > 0)
.Select(x => x.LinkedTransaction.Select(x => x.TransactionId))
.ToList();
下面显示了实际的工作查询。我需要像数字 2 一样在数字 1 中编写代码。
2.
var braughtForwardPaymentId =
from item in braughtForwardInvoices
where item.LinkedTransaction != null
&& item.LinkedTransaction.Count > 0
select string.Join(",", item.LinkedTransaction.Select(x => x.TransactionId)).ToString();
【问题讨论】:
-
你还没有说你想得到什么,所以很难想象你想得到什么:用逗号分隔的项目,一个空格,或者每行放一个项目,或者像@这样的任何东西987654323@,怎么知道???
-
我看到添加的代码:有什么难度?
.Select(x => string.Join(",", x.LinkedTransaction.Select(t => t.TransactionId)).ToString()?