I have some custom code written for SSRS which uses collections and I used linq extension method Min on those collections. I get the error "Min is not a member of System.Collections.Genericlist(of T)"
I tried adding the following reference in the report properties window with no luck.
System.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Here is the code:
Public Function GetMinValue(ByVal a As String, ByVal b As String, ByVal c As String, ByVal d As String)
Dim first As Decimal = System.Convert.ToDecimal(a)
Dim second As Decimal = System.Convert.ToDecimal(b)
Dim third As Decimal = System.Convert.ToDecimal(c)
Dim fourth As Decimal = System.Convert.ToDecimal(d)
Dim itemsList As New System.Collections.Generic.List(Of Decimal)()
If first <> 0 Then itemsList.Add(first)
If second <> 0 Then itemsList.Add(second)
If third <> 0 Then itemsList.Add(third)
If fourth <> 0 Then itemsList.Add(fourth)
Dim smallest As Decimal
Dim count As Integer = itemsList.Count
If count = 0 Then smallest = Nothing
If count > 0 Then smallest = itemsList.Min()
Return smallest
End Function
What am I missing?
Ok! I solved my own problem! We need to use the fully qualified extension method like this.
smallest = System.Linq.Enumerable.Min(itemsList)
instead of calling
itemsList.Min()
Also remember to add reference to System.Linq and System.Core
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With