Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / March 2008

Tip: Looking for answers? Try searching our database.

Anonymous variables with LINQ

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob Develd - 18 Mar 2008 19:51 GMT
Here is my problem :
------------------------------------------------------------------------------------------------------------------------
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
     Dim DataContextFilms As New DataContext(MaConnexion)
     Dim lesFilms = DataContextFilms.GetTable(Of films)()
     Dim dataFilms = From f In lesFilms _
                     Order By f.id_film Descending _
                     Where f.id_film = idFilm _
                     Select f

    ShowMe (dataFilms)
end sub
------------------------------------------------------------------------------------------------------------------------
Wich type of variable can I use to create the procedure 'ShowMe' ?

Sub ShowMe (data as ???????????????????)
   .......
   .......
End Sub
That's perhaps a very simple question, but I am discovering anonymous
type....

------------------------------------------------------------------------------------------------------------------------

ANOTHER QUESTION :

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
     Dim DataContextFilms As New DataContext(MaConnexion)
     Dim lesFilms = DataContextFilms.GetTable(Of films)()
     Dim dataFilms = From f In lesFilms _
                     Order By f.id_film Descending _
                     Where f.id_film = idFilm _
                     Select f
   Dim MyData = dataFilms.tolist
   ShowMe (MyData )
end sub

Wich type can I use to create the procedure 'ShowMe' ?

Sub ShowMe (data as ???????????????????)
   .......
   .......
End Sub

Thanks for help.
Cor Ligthert[MVP] - 19 Mar 2008 06:12 GMT
Bob,

"Showme" is a method in your code which can contain, printing, showing on
screen or printing or whatever, but is definitely not a variable.

Cor

> Here is my problem :
> ------------------------------------------------------------------------------------------------------------------------
[quoted text clipped - 43 lines]
>
> Thanks for help.
Patrice - 19 Mar 2008 13:35 GMT
Try : IQueryable(Of Films) (Though usually it drops the final s but you may
use a different option than we do here).

This is not an anonymous type. As you select all the fields from the table,
the type is still well know. This is actually type inference (ie. if you
over on Datafilms it should display the dbml generated type).

An anonymous type comes in play when you select a subset of the fields (as
in this case you won't have a type that have those members and only these
one so that compilar will create automatically such a type for you).

C'est pour la fête du cinéma ? ;-)

--
Patrice

> Here is my problem :
> ------------------------------------------------------------------------------------------------------------------------
[quoted text clipped - 43 lines]
>
> Thanks for help.
Bob Develd - 19 Mar 2008 14:54 GMT
C'est pour ma base de données de films !
Thanks for your response!

> Try : IQueryable(Of Films) (Though usually it drops the final s but you
> may use a different option than we do here).
[quoted text clipped - 59 lines]
>>
>> Thanks for help.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.