문제

This is currently my Linq query:

result = From d In dc.Tracker
   Where d.Responsible.Value = "first last name"
      Order By d.Priority1, d.Deadline
   Select New With { _
      Key .Title = d.Name, _
      Key .Description = d.Priority1, _
      Key .Priority2= d.Priority2, _
      Key .Status = d.Status, _
      Key .Resp= d.Resp, _
      Key .Deadline = d.Deadline, _
      Key .Notes = d.Notes, _
   }

I am trying to output the data but can only seem to do so doing this:

For Each d In result
   Console.WriteLine(d)
Next

But i can not seem to place it into an array so that i can call it like this:

result(0), result(1), etc etc...

Or even better:

result.Title, result.Description, etc etc...

How can i change that linq into an array?

도움이 되었습니까?

해결책 2

Got it working at least how i am needing it too:

Dim Title As New ArrayList
Dim Description As New ArrayList
Dim Priority2 As New ArrayList
Dim Status As New ArrayList
Dim Resp As New ArrayList
Dim Deadline As New ArrayList
Dim Notes As New ArrayList

result = From d In dc.Tracker
   Where d.Responsible.Value = "first last name"
      Order By d.Priority1, d.Deadline
   Select New With { _
      Key .Title = d.Name, _
      Key .Description = d.Priority1, _
      Key .Priority2= d.Priority2, _
      Key .Status = d.Status, _
      Key .Resp= d.Resp, _
      Key .Deadline = d.Deadline, _
      Key .Notes = d.Notes, _
   }

For Each d In result
    If Not IsNothing(d.Title()) Then Title.Add(d.Title()) Else Title.Add("NA")
    If Not IsNothing(d.Description()) Then Description.Add(d.Description().value) Else Description.Add("NA")
    If Not IsNothing(d.Priority2()) Then Cost.Add(d.Priority2().value) Else Priority2.Add("NA")
    If Not IsNothing(d.Status()) Then Status.Add(d.Status().value) Else Status.Add("NA")
    If Not IsNothing(d.Resp()) Then Responsible.Add(d.Resp().value) Else Resp.Add("NA")
    If Not IsNothing(d.Deadline()) Then Deadline.Add(d.Deadline()) Else Deadline.Add("NA")
    If Not IsNothing(d.Notes()) Then Notes.Add(d.Notes()) Else Notes.Add("NA")
Next

다른 팁

Use the .ToArray() method.

result = (From d In dc.Tracker
          Where d.Responsible.Value = "first last name"
          Order By d.Priority1, d.Deadline
          Select New With { _
           .Title = d.Name, _
           .Description = d.Priority1, _
           .Priority2= d.Priority2, _
           .Status = d.Status, _
           .Resp= d.Resp, _
           .Deadline = d.Deadline, _
           .Notes = d.Notes}).ToArray()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top