Peter Duniho
8/5/2008 9:51:00 PM
On Tue, 05 Aug 2008 14:14:34 -0700, gordigor <gordigor@community.nospam>
wrote:
> This is probably going to be an easy answer, but I can't find it
> anywhere. I want to assign a labels .text property to a field returned
> in a LINQ Query:
> Dim db As New ClientDataContext
>
> Dim ColumnHeaders = From C In db.Customer _
> Select _
> C.Name
>
> //I would expect assignment to work like this but Name doesn't show
> Label.Text = ColumnHeaders.Name
Granted, I'm a relative LINQ newbie. But my understanding is that
ColumnHeaders is a collection, not a single record.
You could include a "Where" clause to limit the results to just one
record, but I think even then you'd still have to extract that one record
explicitly, rather than trying to access the "Name" property directly from
the collection.
This all assumes of course that "db.Customer" is itself a collection. If
not, you may have other problems (or I might just not understand the VB
syntax well enough :) ).
Pete