Lambda Expression X linq

2

Speaking in terms of performance in the whole (speed, integrity and etc ...), use lambda expressions to query database, is it better in terms above or not or depends?

    
asked by anonymous 05.06.2014 / 22:06

2 answers

3

In the case of objects that implement IQueryable , there is the time of the construction of the sentence that consumes some processing, therefore, starting from absolute terms, the sentence in static SQL will be or faster or equivalent to the generated SQL.

However, speaking of integrity and consistency, static SQL alone does not guarantee. All mapping of data between programming language structures needs to be done manually by the programmer , which can produce common errors such as missing columns and / or information that can cause errors in the execution of a flow system.

In the case of Entity Framework , when data persists, the Framework performs some checks automatically, which improves consistency and referential integrity ( does not guarantee 100% ), but improvement). If the code is generated from a database that already exists ( Database First ), the Model objects will reliably copy the database. If the database is generated from the code ( Code First ), any validation placed as a configuration will be replicated to the database.

Comparing one and the other, Expression Methods (common lambda ) and LINQ , there is no difference in performance, since both mount the object IQueryable in a very similar way. The same difference is in the expressiveness of each. Expression Methods are more succinct, while LINQ is more didactic and clear by approaching a natural language, in this case English.

    
05.06.2014 / 22:13
0

Difference is yes. Lambda Expression is more performative than LINQ. Follow the link that proves what I say. link

    
03.11.2014 / 13:34