Santosh Kumar  Kotnala
In Linq Query why from clause come first as select statment ?
By Santosh Kumar Kotnala in SQL Server on May 13 2011
  • Vulpes
    May, 2011 16

    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.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS