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# / April 2008

Tip: Looking for answers? Try searching our database.

why is linq more useful than datasets?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andy B - 19 Apr 2008 01:51 GMT
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...
d-42 - 19 Apr 2008 02:10 GMT
> 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
Jordan S. - 19 Apr 2008 02:42 GMT
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!).

> 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...
Bill Woodruff - 19 Apr 2008 05:43 GMT
Jordan S. wrote :

"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!)."

Isn't that what is supposed to happen at the end of the universe ? It also
sounds suspiciously like great sex.

best, Bill
BlackWasp - 19 Apr 2008 07:37 GMT
Wow!  You have a crowd present?   I can't work out if that is cool or not
(unless you are a rock star).

;-)

Signature

BlackWasp
www.blackwasp.co.uk

> Jordan S. wrote :
>
[quoted text clipped - 6 lines]
>
> best, Bill
Peter Duniho - 19 Apr 2008 07:43 GMT
> 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
BlackWasp - 19 Apr 2008 09:14 GMT
Crowd as a coder I can live with.

It was the crowd for the great sex that I was wondering about.

;-)

Signature

BlackWasp
www.blackwasp.co.uk

>> Wow!  You have a crowd present?   I can't work out if that is cool or
>> not (unless you are a rock star).
[quoted text clipped - 6 lines]
>
> Pete
Jordan S. - 19 Apr 2008 08:00 GMT
> 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.
Angel Rapallo - 20 Apr 2008 05:04 GMT
I think from the little linkq i have read that it indeed has a future though
it might turn out
to be a different future than the one Microsoft had in mind in the first
place. It will
change the way people program completely, i mean linq goest beyond Quering
Arrays,
XML documents or databases, programmers will start writing algorithms based
on linq and programs will take a very unexpected TURN. I dont know if this
will be good
or bad but we will see...

The only thing i felt bad is that the added so much stuff to c# in order to
be able to
add linq that it willnever be the same as before. C# comes froma family of
C-Style
languages which were created during the 60,70 and today such as C,C++,Java
and C#
with this new stuff C# has forsaken its ansertors legacy and it is becoming
something
totally different who would ahve thought about Anonimous Types or Extention
Methods
the closest to things like this was back when languages such as C++ and C
allowed programmers
to write Inline Assembly, but that is something we can do in C# with
Reflection emiting IL code.

I have a theory but I am not gonna saying just in case i am wrong about what
Linq is really all
about what where it came from...to give you a hint if you study Linq closely
it does pretty much
the same things for example a SQL Query Processor would do, it.... maybe
Microsoft
had all this stuff Written from many years ago all those OPERATORS such as
Where, Join etc..

and they EXTENDED C# with something similar..actually I was thinking i could
write and Minature
SQL Server using LINQ........................

hey it is here lets see what happens..and yes this bussines is all about HOW
cool I am or you are
and stuff so everyone out there is set to impress his fellows with his
knowledge unfourtunately
just becuase is cool does not mean is GOOD ..but....

> 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...
Marc Gravell - 20 Apr 2008 09:41 GMT
> Just wondering why linq is more useful than datasets?

If you want a full answer, I recommend LINQ in Action (Manning)

One of the design goals is to provide a uniform approach to querying
data, regardless of the source - query as a first class citizen,
rather than string literals, and without very different-looking code
for each backend. In addition, LINQ-to-SQL (since we are comparing to
datasets) provides composability - meaning that I can take an existing
query - such as the return value from:

var query = GetOpenFoosByCustomer(int customerNumber) {...}

And now I can further compose this:

var query2 = (from foo in query
                 where foo.Value > 200
                 order by foo.Created
                  select new {foo.Token,
foo.Value }).Skip(50).Take(10);

which is filtered, ordered, projected and paged - and when I look at
the results the query that is executed does all of this - i.e. the SQL
will have the extra WHERE and ORDER BY, the SELECT will only have the
two columns, and it will use either TOP or CTE (depending on the
server version) to do the paging.

This can have huge benefits on data throughput; I've reduced the
bandwidth by reducing the data volume before it left the database.

Now consider that this can be accessed through something like Astoria
(sorry, ADO.NET Data Services) - which is doing the same thing over a
web-service; minimising data throughput in distributed systems is a
"must"; but an Astoria query will look identical to a LINQ-to-SQL
query [caveat; Astoria doesn't currently support projections - only
homogenous sets].

Marc
Marc Scheuner - 20 Apr 2008 12:12 GMT
>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
Andy B - 20 Apr 2008 16:22 GMT
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?

> >Just wondering why linq is more useful than datasets? The stuff I do
> >doesn't
[quoted text clipped - 27 lines]
>
> Marc
Marc Scheuner - 21 Apr 2008 05:59 GMT
>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

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.