Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Tue, 5 Aug 2008 15:14:34 -0600,    group: microsoft.public.dotnet.framework        back       


LINQ in label   
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

What's the correct way?
date: Tue, 5 Aug 2008 15:14:34 -0600   author:   gordigor am

Re: LINQ in label   
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
date: Tue, 05 Aug 2008 14:51:28 -0700   author:   Peter Duniho

Re: LINQ in label   
gordigor 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
> 
> What's the correct way?

There doesn't seem to be any reason to use LINQ at all?

Why not simply something like:

Label.Text = db.Customer.First().Name

-- 
Göran Andersson
_____
http://www.guffa.com
date: Wed, 06 Aug 2008 02:40:25 +0200   author:   Göran Andersson

Re: LINQ in label   
"Göran Andersson"  wrote in message 
news:%23HhsE019IHA.3344@TK2MSFTNGP02.phx.gbl...
> gordigor 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
>>
>> What's the correct way?
>
> There doesn't seem to be any reason to use LINQ at all?
>
> Why not simply something like:
>
> Label.Text = db.Customer.First().Name
>
> -- 
> Göran Andersson
> _____
> http://www.guffa.com

Ok. I was confused. Still I don't see the actual fields if I do Label.Text = 
db.Customer
date: Wed, 6 Aug 2008 10:09:47 -0600   author:   gordigor am

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us