Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding system.linq reference to ssrs custom code

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?

like image 792
user1176058 Avatar asked Mar 27 '26 18:03

user1176058


1 Answers

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.

like image 150
user1176058 Avatar answered Mar 30 '26 10:03

user1176058



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!