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# / October 2007

Tip: Looking for answers? Try searching our database.

Weird design decision in LinQ To SQL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
teddysnips@hotmail.com - 19 Oct 2007 13:54 GMT
I'm taking a look at LinQ to SQL and I'm mystified by a design
decision taken by the language design mavens.

Take this simple snipple:

var q =
  from c in db.Customers
  where c.City == "London"
  select c.CompanyName;

Why is this not in the order that standard SQL takes - e.g.

var q =
  select c.CompanyName
  from c in db.Customers
  where c.City == "London";

It Just Doesn't Make Sense.

Edward
Marc Gravell - 19 Oct 2007 14:06 GMT
Actually, getting the "from" first makes a lot MORE sense IMO, and you
can see how this allows everything that follows to make better use of
intellisense etc; how can it tell you what you can select if you
haven't told it what you are talking about first?
Jon Skeet [C# MVP] - 19 Oct 2007 14:13 GMT
> Actually, getting the "from" first makes a lot MORE sense IMO, and you
> can see how this allows everything that follows to make better use of
> intellisense etc; how can it tell you what you can select if you
> haven't told it what you are talking about first?

Exactly. If you draw a diagram of what sequence is represented at
every stage, it makes perfect sense with LINQ queries - it goes from
top to bottom.

Not that I've been drawing that kind of diagram myself, of course ;)

Jon
Nicholas Paldino [.NET/C# MVP] - 19 Oct 2007 15:11 GMT
The opening chapter of "Inside SQL Server 2005: T-SQL Querying" actually
takes a SQL statement with joins, where, and an order clause and breaks down
exactly how SQL Server (and most RDBMSs) would handle it.  The data source
(from, and joins) are always processed first, with the select processed
last.

   Anders has even stated that this is more natural to him, given how SQL
queries are processed.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

>> Actually, getting the "from" first makes a lot MORE sense IMO, and you
>> can see how this allows everything that follows to make better use of
[quoted text clipped - 8 lines]
>
> Jon
Jon Skeet [C# MVP] - 19 Oct 2007 17:53 GMT
On Oct 19, 3:11 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.com> wrote:
>     The opening chapter of "Inside SQL Server 2005: T-SQL Querying" actually
> takes a SQL statement with joins, where, and an order clause and breaks down
[quoted text clipped - 4 lines]
>     Anders has even stated that this is more natural to him, given how SQL
> queries are processed.

Exactly - without the context of the data source, the "select" doesn't
make any sense at all. The engine can't really do anything with it
until it's looked at the rest of the query.

Jon
Ignacio Machin ( .NET/ C# MVP ) - 19 Oct 2007 15:00 GMT
Hi,

Have you stopped to think that maybe the way you always did it is not the
correct one?
:-)

Signature

Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.

> I'm taking a look at LinQ to SQL and I'm mystified by a design
> decision taken by the language design mavens.
[quoted text clipped - 16 lines]
>
> Edward
Cor Ligthert[MVP] - 20 Oct 2007 11:01 GMT
Teddy,

For me is SQL always been a very difficult dialect to understand. (I was
already a devellopper before the time it was created, therefore I learned it
never on school).

From the start all languages were describing what to take and then what to
do with it. And that always from the top to the bottom.

In the seventies there came as SQL meant as an enduser scripting language to
be in Plain English  (whatever that distincts that "Plain" from real English
are in my idea words as Drop, Truncate and things as that). For the latter,
I am not an Englishman and as somebody here from the area of the real Oxford
tells me that it is plain English, then I believe him of course.

However, for me (as an old developper from before the start of SQL) has SQL
forever been the most unlogical developper language that was ever designed.

Just my 2 cents.

Cor
Arto Viitanen - 22 Oct 2007 06:07 GMT
teddysnips@hotmail.com kirjoitti:
> I'm taking a look at LinQ to SQL and I'm mystified by a design
> decision taken by the language design mavens.
[quoted text clipped - 12 lines]
>    from c in db.Customers
>    where c.City == "London";

Well SQL is based (mainly) or relational algebra, and in relational
algebra you would tell this

Project(CompanyName,
   Restrict(City='London',
      Customers))

Which is a little bit closer to the way you say in SQL. So yes, SQL
(almost) makes sence.

--
Arto Viitanen

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.