0
votes

I have the following query which groups some records and then filters where the count of the grouped records is 1.

I'd like to take the returned result and perform another query to retrieve the entire record from the JobcodesWorkingRollup table where the ParentNode column equals the result of this query:

        Dim query = From r In context.GetTable(Of JobcodesWorkingRollup)() _
        Group r By r.ParentNode Into g = Group _
        Where g.Count = 1 _
        Select New With {.cnt = g.Count, .nm = g.FirstOrDefault.ParentNode}

Thanks!

1
I don’t understand what you’re trying to do. What is returnedResult? A (e.g. the first) result returned by query?Konrad Rudolph
yes returned result is the object returned from the first query. It will have cnt = 1, and .nm equal to a string value.Steve

1 Answers

0
votes

I think I have it... is there a better way?

        Dim query = From r In context.GetTable(Of JobcodesWorkingRollup)() _
        Group r By r.ParentNode Into g = Group _
        Where g.Count = 1 _
        From rr In context.GetTable(Of JobcodesWorkingRollup)() _
        Where rr.ParentNode = g.FirstOrDefault.ParentNode _
        Select New With {.record = rr}