Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
iOS
Java
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
1
Reply
In Linq Query why from clause come first as select statment ?
Santosh Kumar Kotnala
13y
7.4k
0
Reply
Submit
It comes first because, in C#, you can't access variables before they are declared.
So, in this query:
var query = from c in "abcde" select c;
we can access 'c' in the select clause because it's already been declared in the from clause and the compiler has inferred it to be of type 'char' because a string is an IEnumerable<char>.
Also, whilst LINQ queries may look a bit like SQL, they're actual based on something called a 'list comprehension' in functional programming languages such as LISP. Consequently, there was no need to change C#'s natural way of doing things to be compatible with SQL.
Vulpes
13y
0
Message