我有以下代码
de.Tbl_Summary.Where(Function(c) CBool(c.CPID = uPn AndAlso _
c.C_Year = cutoffDates.ActualClaimYear AndAlso _
c.C_Month >= cutoffDates.ActualClaimMonth _
)).ToList().ForEach(Function(r) InlineAssignHelper(r.TeamID, uTid))
是从C#示例转换和改编的。这工作正常,但我现在需要更新两个字段,所以我尝试了...
de.Tbl_Summary.Where(Function(c) CBool(c.CPID = uPn AndAlso _
c.C_Year = cutoffDates.ActualClaimYear AndAlso _
c.C_Month >= cutoffDates.ActualClaimMonth _
)).ToList().ForEach(Function(r) InlineAssignHelper(r.TeamID, uTid), _
InlineAssignHelper(r.CostCentre, uCostCentre))
这不起作用,因为我在第二个InLineAssignHelper下面出现了一条带有错误的波浪线
Error BC30057 Too many arguments to 'Public Overloads Sub
ForEach(action As Action(Of Tbl_IndividualClaims))'.
如何实现将更新TblIndividualClaims中的2个字段的ForEach?
由于
更新
这是InlineAssignHelper的VB转换代码(从C#转换而来)
Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
target = value
Return value
End Function
答案 0 :(得分:0)
如果你绝对必须保持相同的格式,那么它最终会如此:
.ForEach(Function(r)
InlineAssignHelper(r.TeamID, uTid)
InlineAssignHelper(r.CostCentre, uCostCentre)
End Function)
P.S。在这种情况下使用Sub
更有意义