blah blah blah is here! blah blah » Close

up0down
link

Hi all,
I am trying to use a LINQ query in C# but it seems that VS is not recognizing the syntax. I have VS 2005 and .NET 3.5 installed.
The following is the code:
IEnumerable <db4o> retrieve = from db4o p in db
where p.Name.StartsWith("Hello");
select p;
The errors are like:
error CS1525: Invalid expression term 'in'
what possibly could be the reason..

last answered 8 months ago

1 answers

up0down
link

I have also added
using System.Linq at the start..
It does not give any errors..
so m confused whether it is supporting linq or not..

up0down
link

I think your problem here is that LINQ requires C# 3.0 (for query syntax, extension methods, lambda expressions etc) but Visual Studio 2005 is hard-wired to use the C# 2.0 compiler.
I don't know whether there's a way to force VS 2005 to use C# 3.0 (<a target="_new" href="http://www.pvle.be/2008/10/linq-in-visual-studio-2005/">this link</a> shows how you can work around it).
What I do know is that if you download the free <a target="_new" href="http://www.microsoft.com/express/vcsharp/">VC# 2008 Express</a> (or even the <a target="_new" href="http://www.microsoft.com/express/future/default.aspx">VC# 2010 Express Beta 2</a> which seems quite stable) you can use LINQ without problem and that these co-exist fine with VS 2005 on the same machine.

up0down
link

Hi Vulpes,
Thanks for the guidance. The idea of VC# 2008 along with the current 2005 looks gr8. I'll give it a try.
Thanks again.
Regards,
Abhi

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback