1
Reply

In Linq Query why from clause come first as select statment ?

    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.