By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,266 Members | 1,862 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,266 IT Pros & Developers. It's quick & easy.

Linq - basic simple Answer

P: n/a
Hi all:
after reading different places/sites about linq... I ran into these questions:

1. What framework do we need to run linq ?
(does it depend on what version of visual studio we have?)
how about vs2008?
is it different name space or framework for linq xml or linq sql? (
2. do we need to have references to what linq's dlls. or namespaces?
system core?
3. what name spaces are needed?
4. what is the earliest framework where linq can run?
5. C# vs2008 what else?

thanks for taking the time to clearing this out.

Jul 7 '08 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On Jul 7, 3:51*pm, raulavi <raul...@discussions.microsoft.comwrote:
after reading different places/sites about linq... I ran into these questions:

1. What framework do we need to run linq ?
That depends on what you mean by LINQ. LINQ to Objects can be run
in .NET 2.0 so long as you have a suitable implementation, such as
LINQBridge (search to find it).
LINQ to XML (and other out-of-process LINQ providers) require
expression trees, which in turn require .NET 3.5.
* *(does it depend on what version of visual studio we have?)
* *how about vs2008?
To be running LINQ "properly" (i.e. with real language integration)
you need to be using C# 3 or VB9, both of which require VS 2008 (or a
text editor with .NET 3.5 installed).
* *is it different name space or framework for linq xml or linq sql? (
2. do we need to have references to what linq's dlls. or namespaces?
* *system core?
You need System.Core for various bits (assuming you want to use the
built-in providers). I can't remember whether the LINQ to XML and LINQ
to SQL classes live - but you could look them up in MSDN.
3. what name spaces are needed?
Again, that depends on the provider you're using. For LINQ to Objects,
you just need System.Linq.
4. what is the earliest framework where linq can run?
See answer to question 1.
*5. C# vs2008 what else?
What do you mean?

Jon
Jul 7 '08 #2

P: n/a
Thanks Jon:
That depends on what you mean by LINQ. LINQ to Objects can be run
in .NET 2.0
lets start with LinQ to Objects. (net.2.0)
then we need .Net3.5 (correct) to support lambdas to expression trees
(i.e., Expression<TDelegate>)
... LINQ to Objects can be run
in .NET 2.0 so long as you have a suitable implementation, such as
LINQBridge (search to find it).
I read about it. very good dll, limited
allowing you to use C# 3.0's extension methods in Framework 2.0.
http://www.albahari.com/nutshell/linqbridge.html

Again, that depends on the provider you're using. For LINQ to Objects,
you just need System.Linq.
I got project properties to target net3.5 , i added the system.core to the
project's references ,and cannot add my using System.Linq (intellisense does
not show it up) and compiler reported as error , Any clue?

5. C# vs2008 what else?
What do you mean?
I meant, anything else to run Linq in C# using visual studio 2008.
but, you already give me the answers, (the clue is that linq is a group of
things
not just a single dll, part of my confusion)
Thanks
(I like the way you anwser everyone's question, you detail answers a little
bit more
Knowing that we want to catch up, thanks for that).


"Jon Skeet [C# MVP]" wrote:
On Jul 7, 3:51 pm, raulavi <raul...@discussions.microsoft.comwrote:
after reading different places/sites about linq... I ran into these questions:

1. What framework do we need to run linq ?

That depends on what you mean by LINQ. LINQ to Objects can be run
in .NET 2.0 so long as you have a suitable implementation, such as
LINQBridge (search to find it).
I read about it. very good dll, very limited
allowing you to use C# 3.0's extension methods in Framework 2.0.

http://www.albahari.com/nutshell/linqbridge.html
LINQ to XML (and other out-of-process LINQ providers) require
expression trees, which in turn require .NET 3.5.
(does it depend on what version of visual studio we have?)
how about vs2008?

To be running LINQ "properly" (i.e. with real language integration)
you need to be using C# 3 or VB9, both of which require VS 2008 (or a
text editor with .NET 3.5 installed).
is it different name space or framework for linq xml or linq sql? (
2. do we need to have references to what linq's dlls. or namespaces?
system core?

You need System.Core for various bits (assuming you want to use the
built-in providers). I can't remember whether the LINQ to XML and LINQ
to SQL classes live - but you could look them up in MSDN.
3. what name spaces are needed?

Again, that depends on the provider you're using. For LINQ to Objects,
you just need System.Linq.
4. what is the earliest framework where linq can run?

See answer to question 1.
5. C# vs2008 what else?

What do you mean?

Jon
Jul 7 '08 #3

P: n/a
raulavi <ra*****@discussions.microsoft.comwrote:
That depends on what you mean by LINQ. LINQ to Objects can be run
in .NET 2.0
lets start with LinQ to Objects. (net.2.0)
then we need .Net3.5 (correct) to support lambdas to expression trees
(i.e., Expression<TDelegate>)
Yes.
... LINQ to Objects can be run
in .NET 2.0 so long as you have a suitable implementation, such as
LINQBridge (search to find it).
I read about it. very good dll, limited
allowing you to use C# 3.0's extension methods in Framework 2.0.
http://www.albahari.com/nutshell/linqbridge.html
It lets you use extension methods (which is the easy bit) *and* it's an
implementation of LINQ to Objects.
Again, that depends on the provider you're using. For LINQ to Objects,
you just need System.Linq.

I got project properties to target net3.5 , i added the system.core to the
project's references ,and cannot add my using System.Linq (intellisense does
not show it up) and compiler reported as error , Any clue?
No idea, I'm afraid - certainly System.Linq.Enumerable is in the
System.Core assembly, for example.

What error are you getting?

If you set the project to target .NET 3.5, I would expect System.Core
to be in the default set of references, by the way.
5. C# vs2008 what else?
What do you mean?
I meant, anything else to run Linq in C# using visual studio 2008.
but, you already give me the answers, (the clue is that linq is a group of
things not just a single dll, part of my confusion)
Yes, it's a fairly vaguely defined term, unfortunately. That's why it's
tricky when someone says "I'm using LINQ to do X" but without making it
clear which "flavour" of LINQ they're using :(
Thanks
(I like the way you anwser everyone's question, you detail answers a little
bit more Knowing that we want to catch up, thanks for that).
My pleasure - glad it helps.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon_skeet
C# in Depth: http://csharpindepth.com
Jul 7 '08 #4

P: n/a
On Jul 7, 7:07*pm, "Jon Skeet [C# MVP]" <sk...@pobox.comwrote:
LINQ to XML (and other out-of-process LINQ providers) require
expression trees, which in turn require .NET 3.5.
This isn't quite true, as LINQ to XML in particular does not work with
expression trees - all it does is providing a set of "axis" methods
such as Ancestors() or Attributes(), that return IEnumerable of some
XObject-derived type, which can then be queried using LINQ to Objects
as usual. As such, it is quite possible to implement LINQ to XML on
top of .NET 2.0, in the same manner as LINQbridge.
You need System.Core for various bits (assuming you want to use the
built-in providers). I can't remember whether the LINQ to XML and LINQ
to SQL classes live - but you could look them up in MSDN.
It's System.Xml.Linq.dll and System.Data.Linq.dll, respectively - same
as namespaces.

As I recall, System.Xml.Linq is actually added to a new project
references by default if target is set to 3.5.
Jul 7 '08 #5

P: n/a
Pavel Minaev <in****@gmail.comwrote:
LINQ to XML (and other out-of-process LINQ providers) require
expression trees, which in turn require .NET 3.5.

This isn't quite true, as LINQ to XML in particular does not work with
expression trees - all it does is providing a set of "axis" methods
such as Ancestors() or Attributes(), that return IEnumerable of some
XObject-derived type, which can then be queried using LINQ to Objects
as usual. As such, it is quite possible to implement LINQ to XML on
top of .NET 2.0, in the same manner as LINQbridge.
You're right, of course. I don't know what I was thinking. Apologies.
Doh!

The same is true of LINQ to DataSets too.
You need System.Core for various bits (assuming you want to use the
built-in providers). I can't remember whether the LINQ to XML and LINQ
to SQL classes live - but you could look them up in MSDN.

It's System.Xml.Linq.dll and System.Data.Linq.dll, respectively - same
as namespaces.
And LINQ to DataSets is in System.Data.DataSetExtensions.
As I recall, System.Xml.Linq is actually added to a new project
references by default if target is set to 3.5.
Yup - ditto System.Core though, which makes me wonder about raulavi's
follow-up post...

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon_skeet
C# in Depth: http://csharpindepth.com
Jul 7 '08 #6

P: n/a
raulavi wrote:
I got project properties to target net3.5 , i added the system.core
to the project's references ,and cannot add my using System.Linq
(intellisense does not show it up) and compiler reported as error ,
Any clue?
Did the project originally target 2.0 and then you changed it to 3.5?
if so you probably just need to add the assembly reference manually.

Cheers Tim.
Jul 7 '08 #7

P: n/a
Thanks Tim:
You are right, changed proj from 2.0 to 3.5
but, I got to closed IDE and reopened and did the trick. ODD!!
if so you probably just need to add the assembly reference manually.
manually...what do you mean.


"Tim Jarvis" wrote:
raulavi wrote:
I got project properties to target net3.5 , i added the system.core
to the project's references ,and cannot add my using System.Linq
(intellisense does not show it up) and compiler reported as error ,
Any clue?

Did the project originally target 2.0 and then you changed it to 3.5?
if so you probably just need to add the assembly reference manually.

Cheers Tim.
Jul 8 '08 #8

P: n/a
still lot to learn!

Thanks to all.
I got better understanding now.

Jul 8 '08 #9

P: n/a
raulavi wrote:
Thanks Tim:
You are right, changed proj from 2.0 to 3.5
but, I got to closed IDE and reopened and did the trick. ODD!!
Ah cool, glad it got sorted. I didn't know that VS would auto add the
reference to an updated project after a restart, thats cool as it would
have been a minor PITA otherwise.
if so you probably just need to add the assembly reference manually.
manually...what do you mean.
Oh adding an assembly reference manually is just a matter of right
clicking the references entry in the solution explorer and selecting
add reference from the context menu then navigating to the assembly
that you want to add. Though in your case a restart is way better as
you would have been re-adding system assemblies from the later (3.5)
framework directory, much nicer and easier that VS did it for you.

Cheers Tim.

--

Jul 8 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.