Nakul Chaudhari
Why , "SELECT" after "FROM" in LINQ ?
By Nakul Chaudhari in LINQ on Oct 16 2014
  • Sachin Karche
    Dec, 2020 17

    FROM is used first because of for loop. In
    From var in list - syntax trying to match with for look.

    may another reason it used for select later so we can use anonymus type to select required output.

    • 0
  • Prakash Lakshmanan
    Dec, 2014 15

    check this url: http://www.codeproject.com/Articles/19154/Understanding-LINQ-C

    • 0
  • Vithal Wadje
    Nov, 2014 2

    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();

    • 0
  • Anupam Singh
    Nov, 2014 2

    interesting question agreed with Murugesh.

    • 0
  • Murugesh P
    Oct, 2014 31

    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

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS