Pass Linq query result with Intellisense?

J

John

Is it possible to pass a LINQ query result to a Sub and not lose
Intellisense to the Fields returned.

Example:

Public Sub DoPriceListQuery()

Dim dbCus As New DataAPDataContext
Dim Price = (From c In dbCus.tblPriceLists _
Where c.Disabled = False _
And c.OwnerID = 1 _
Select c).ToArray


'have intellisense to fields returned in query
EditWeb(Price)


dbCus.SubmitChanges()
End Sub

Private Sub EditWeb(ByRef Price As Array)

For Each p in Price
With p

'lose Intellisense here but code works

End With
Next

End Sub
 
M

Mr. Arnold

John said:
Is it possible to pass a LINQ query result to a Sub and not lose
Intellisense to the Fields returned.
Yes

Example:

Public Sub DoPriceListQuery()

Dim dbCus As New DataAPDataContext
Dim Price = (From c In dbCus.tblPriceLists _
Where c.Disabled = False _
And c.OwnerID = 1 _
Select c).ToArray

which would result in a strong list of said:
'have intellisense to fields returned in query
EditWeb(Price)


dbCus.SubmitChanges()
End Sub

Private Sub EditWeb(IEnumerable<Price> as prices)

For Each p in Price
With p

ForEach var p in prices
with p

And you should have intellisense on the 'price' object in prices now.
'lose Intellisense here but code works

End With
Next

End Sub


You're using VB, and I do it with C#. So I'll assume you can use a "var" in
VB.NET like you can in C#. Also, some of my usage of VB is not 100% anymore
but the usage of List<t> and IEnumerable<t> are the same between the two
languages.
 
J

John

Thanks to all
this worked
Private Sub EditWeb(ByRef Price As IEnumerable(Of tblPriceList)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top