Why , "SELECT" after "FROM" in LINQ ?
Nakul Chaudhari
check this url: http://www.codeproject.com/Articles/19154/Understanding-LINQ-C
Not really sure how your quadupuled posted, but I think have seen you previously double posted. Be careful with the submit button, let the page load after you click it. It is annoying and inconsistant have multiple posts for the same topic.See the following links.http://msdn.microsoft.com/en-us/library/bb383978.aspxhttp://msdn.microsoft.com/en-us/library/bb384087.aspxAlthough the linq syntax is similar to SQL it can be used completely without SQL. The "from clause" starts the expression tree, selects the datasource, and declares the local ranged variable for each element. It is more similar to "foreach". In order to get your range variable hard typed you need to put that before your query. It is similar to "SELECT * FROM Table AS [LocalVariable]".Scheme and Lisp were very very early (maybe even the first) programming languages. They are very fast, but hard to understand. This is due to the order of which you must write your procedures. SQL uses the Scheme syntax, but different functionality. The LINQ syntax reordered the sql structure which I find more in order of writing an query. At first it was hard, but after I memorized the syntax I can write it alot faster than SQL.Other than that the layout may also have to do with the expression tree it creates. DataContext dc = new DataContext;//LINQ Syntax var results = (from row in dc.Table where row.IsValid select row.Id).ToList();//Is the same as Methods Syntax var results2 = dc.Table.Where(row => row.IsValid). Select(row => row.Id).ToList();
interesting question agreed with Murugesh.
The reason is, LINQ is used with C# or other programming languages, which requires all the variables to be declared first. From clause of LINQ query just defines the range or conditions to select records. So that's why from clause must appear before Select in LINQ