我想我应该使用'聚合',但显然我错了
首先,我获得了一个实体对象列表
Dim employers As List(Of myEntity) = (New XXXX()).getZZZ(userName, userType)
然后我认为这是一种将所有名字放在字符串中的方法
Dim names as String = employers.Aggregate(Function(current, [next]) current.Name & " " & [next].Name)
但我得到错误:“无法将类型'lambda表达式'转换为参数类型'System.Func(myEntity,myEntity,myEntity ......”
任何线索?
答案 0 :(得分:4)
请改为尝试:
Dim names = String.Join(" ", employers.Select(Function(employer) employer.Name))
答案 1 :(得分:0)
Dim names as String = employers.Aggregate("", Function(current, [next]) current & " " & [next].Name)
' Use this ^^ ^^
您可能希望之后修剪字符串,因为它将以空格开头。
答案 2 :(得分:-1)
尝试:
Dim names as String = employers.Select(Function(emp) emp.Name ).Aggregate(Function(current, [next]) current & " " & [next])