我不是VB的粉丝。任何人都可以帮助我在c#中创建这段代码吗?什么是VB Linq中Aggregate关键字的C#等价物?
Public ReadOnly Property HasErrors() As Boolean
Get
Return (Aggregate o In Me _
Let errObj = TryCast(o, IDataErrorInfo) _
Where If(errObj IsNot Nothing, errObj.Error <> Nothing, False) _
Into Count()) > 0
End Get
End Property
更新
Public MustInherit Class MyBaseCollection(Of T)
Inherits ObservableCollection(Of T)
Public ReadOnly Property HasErrors() As Boolean
Get
Return (Aggregate o In Me _
Let errObj = TryCast(o, IDataErrorInfo) _
Where If(errObj IsNot Nothing, errObj.Error <> Nothing, False) _
Into Count()) > 0
End Get
End Property
Sub New(ByVal query As IEnumerable(Of T), ByVal context As OMSEntities)
MyBase.New(query)
End Sub
End Class
我尝试使用在线代码转换它来转换。但是我最终得到了未编译的代码。 – sovantha