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 / C# / July 2007

Tip: Looking for answers? Try searching our database.

LINQ sentence error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pedro - 16 Jul 2007 18:24 GMT
Hi

I have VS .NET 2005 and I install LinQ preview for C#.
I'm try to make some thing using LINQ.

IT returns error in this sentence :

var query = from p in people.People
                  from s in people.Salaries
                  where p.ID == s.ID)
                  select new { p.LastName, p.FirstName, s.Year,
s.SalaryYear};

And don't recognize this Sintax.

I will be grateful for your help

Signature

Thanks ,

Pedro

David R. Longnecker - 16 Jul 2007 18:40 GMT
First off, be sure you have added the right references to your project. You'll
need a using statement for System.Linq.

Looking at your LINQ code, It may be just your extra ) in there.  Do you
have your foreign key relationships defined (the p.ID = s.ID) in the designer?
If so, the additional "join" shouldn't be necessary.

var query =
 from p in people.People
 select new { p.LastName, p.FirstName, p.Salaries.Year, p.Salaries.SalaryYear
};

If not, then your query looks good, but it'd be based on the data layout
you have designed.  

var query =
 from p in people.People
 from s in people.Salaries
 where p.ID == s.ID
 select new { p.LastName, p.FirstName, s.Year, s.SalaryYear };

If it still isn't working, could you maybe post up what the actual compiler
error is?

HTH.

-dl

--
David R. Longnecker
http://blog.tiredstudent.com

> Hi
>
[quoted text clipped - 13 lines]
>
> Pedro

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.