none
Left outer join Dataset to LINQ to Gridview RRS feed

  • Question

  •  

    I am attempting to use LINQ to perform a left outer join on two DataSets.  When it iterate through the query it throws

    'Value cannot be null. Parameter name: row' on the first row that is non-matching.  thanks for the help.

     

    Dim dsCRAresources As DataSet = getCRAresources()

    Dim dsSalesGoalsValues As DataSet = getSalesGoalsValues()

     

    Dim Resources As DataTable = dsCRAresources.Tables(0) ' 149 rows

    Dim Goals As DataTable = dsSalesGoalsValues.Tables(0) ' 1 row

     

    Dim query = _

        From resource In Resources.AsEnumerable() _

        Group Join goal In Goals.AsEnumerable() _

        On Trim(resource.Field(Of String)("resourceLoginid")) Equals Trim(goal.Field(Of String)("UserLogin")) _

        Into children = Group _

        From child In children.DefaultIfEmpty() _

        Select New With { _

                                    .resourcename = resource.Field(Of String)("resourcename"), _

                                    .CheckingAccountSales = child.Field(Of Integer)("CheckingAccountSales") _

                                  }

     

    For Each resource In query

        Dim resname = resource.resourcename

    Next ' throws exception on row 2

    Tuesday, April 29, 2008 6:57 PM