【问题标题】:Adding system.linq reference to ssrs custom code添加对 ssrs 自定义代码的 system.linq 引用
【发布时间】:2015-06-16 14:53:57
【问题描述】:

我为使用集合的 SSRS 编写了一些自定义代码,并且我在这些集合上使用了 linq 扩展方法 Min。我收到错误消息“Min 不是 System.Collections.Genericlist(of T) 的成员”

我尝试在报告属性窗口中添加以下引用,但没有成功。

System.Linq,版本=4.0.0.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a

代码如下:

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

我错过了什么?

【问题讨论】:

    标签: vb.net reporting-services


    【解决方案1】:

    好的!我解决了我自己的问题!我们需要像这样使用完全限定的扩展方法。

    smallest = System.Linq.Enumerable.Min(itemsList)
    

    而不是调用

    itemsList.Min()
    

    还要记得添加对 System.Linq 和 System.Core 的引用

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多