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

why is linq more useful than datasets?

P: n/a
Just wondering why linq is more useful than datasets? The stuff I do doesn't
seem to be too complicated to use linq with it. If I did use linq with it
now, I would be doing almost the exact same programming, just with a
different data getting process...

Jun 27 '08 #1
Share this Question
Share on Google+
7 Replies


P: n/a
On Apr 18, 5:51 pm, "Andy B" <a_bo...@sbcglobal.netwrote:
Just wondering why linq is more useful than datasets? The stuff I do doesn't
seem to be too complicated to use linq with it. If I did use linq with it
now, I would be doing almost the exact same programming, just with a
different data getting process...
1) Linq is much more broadly applicable than datasets.
You can do a linq query against a collection of plain old clr objects
for example, without a database in sight.

Suppose I have a dictionary collection of key/values and I want all
the objects where the key < 5 or the value is "blue"

var myPairs = from p in myDictionary where (p.key < 5) || (p.value ==
"blue") select p;

is probably one of the most readable and most concise ways of
expressing that that I've ever seen.

2) linq to sql vs strongly typed datasets?
I wouldn't say linq to sql is more useful than strongly type datasets,
just different.
If you want to represent your data as objects, linq to sql makes that
path much easier.
If you prefer working with datasets then keep on trucking.

cheers,
Dave
Jun 27 '08 #2

P: n/a
And.... the number 1 reason to use linq (drum roll).... (extended drum
roll)... you want to be cool. (the crowd goes wild! the heavens open, and
the angels sing!).


"Andy B" <a_*****@sbcglobal.netwrote in message
news:uh**************@TK2MSFTNGP04.phx.gbl...
Just wondering why linq is more useful than datasets? The stuff I do
doesn't seem to be too complicated to use linq with it. If I did use linq
with it now, I would be doing almost the exact same programming, just with
a different data getting process...


Jun 27 '08 #3

P: n/a
On Fri, 18 Apr 2008 23:37:13 -0700, BlackWasp <nospam@pleasewrote:
Wow! You have a crowd present? I can't work out if that is cool or
not (unless you are a rock star).
I think if you're a coder with a crowd for an audience, that's got to be
more cool than the guy who's a rock star.

After all, it pretty much goes with the territory if you're a rock star
(yawn). But I don't know very many coders who have that. :)

Pete
Jun 27 '08 #4

P: n/a
Wow! You have a crowd present? I can't work out if that is cool or not
(unless you are a rock star).
Well, I'm working on the crowd, but I do have a drummer. The whole "extended
drum roll" thing (which can go for _really_ long time) can be annoying. But
it sure takes the tedium out of heads-down coding! Spandex zebra pants and
long hair are next on my "to do" list.

Jun 27 '08 #5

P: n/a
>Just wondering why linq is more useful than datasets? The stuff I do doesn't
>seem to be too complicated to use linq with it. If I did use linq with it
now, I would be doing almost the exact same programming, just with a
different data getting process...
The single BIGGEST reason to use LINQ over "traditional" ADO.NET style
programming is type safety.

If you use traditional ADO.NET with SqlConnection, SqlCommand and so
forth, you define your queries as strings in C# - no compile time
error checking possible, e.g. if you mistype a single character and
specify "SELECT Naame......." instead of "SELECT Name.....", you'll
only find out at runtime due to either a crash or no data being
returned.

With LINQ (to SQL), you get a type-safe, compile-time checkable
syntax, so if you happen to write

var q = from myTable
where .......
select new { Naame,. ......}

you'll immediately get the compiler barfing at you, since you mistyped
a field name.

And of course, with the type-checking also comes Intellisense - you'll
never get THAT when typing up your queries in a string inside a C#
method.....

Marc
Jun 27 '08 #6

P: n/a
Ok... so I am convinced that linq in whatever form it has is better than
datasets. Now, is there any online tutorials (no pdf files or videos) out
there that are good enough to use so I can figure this stuff out?
"Marc Scheuner" <no*****@for.mewrote in message
news:o2********************************@4ax.com...
Just wondering why linq is more useful than datasets? The stuff I do
doesn't
seem to be too complicated to use linq with it. If I did use linq with it
now, I would be doing almost the exact same programming, just with a
different data getting process...

The single BIGGEST reason to use LINQ over "traditional" ADO.NET style
programming is type safety.

If you use traditional ADO.NET with SqlConnection, SqlCommand and so
forth, you define your queries as strings in C# - no compile time
error checking possible, e.g. if you mistype a single character and
specify "SELECT Naame......." instead of "SELECT Name.....", you'll
only find out at runtime due to either a crash or no data being
returned.

With LINQ (to SQL), you get a type-safe, compile-time checkable
syntax, so if you happen to write

var q = from myTable
where .......
select new { Naame,. ......}

you'll immediately get the compiler barfing at you, since you mistyped
a field name.

And of course, with the type-checking also comes Intellisense - you'll
never get THAT when typing up your queries in a string inside a C#
method.....

Marc

Jun 27 '08 #7

P: n/a
>Ok... so I am convinced that linq in whatever form it has is better than
>datasets. Now, is there any online tutorials (no pdf files or videos) out
there that are good enough to use so I can figure this stuff out?
There are LOADS of resources out there - this might get you started -
a series of 9 10-20 min. videos about LINQ:

http://www.asp.net/learn/linq-videos/

Marc
Jun 27 '08 #8

This discussion thread is closed

Replies have been disabled for this discussion.