Changes

Jump to navigation Jump to search
933 bytes added ,  01:32, October 27, 2009
no edit summary
Line 18: Line 18:  
</pre></code>
 
</pre></code>
 
An interesting point is the fact that the select statement comes last, instead of in SQL where the projection is always the first statement. This is because having the projection first would not be syntactically correct in .NET, where all variables must be declared before using them.
 
An interesting point is the fact that the select statement comes last, instead of in SQL where the projection is always the first statement. This is because having the projection first would not be syntactically correct in .NET, where all variables must be declared before using them.
 +
 +
LINQ became especially useful for development groups who had coded in a proper object oriented (OO) fashion, utilizing generic properties of custom business objects, for example, a method with the following signature:
 +
 +
<code>
 +
<pre>
 +
Public Function Departments() As Generic.IList(of Depertment)
 +
</pre>
 +
</code>
 +
 +
Could suddenly be included in a Linq query, as the IList interface implements IEnumerable, thus:
 +
<code>
 +
<pre>
 +
Dim eCollection As IEnumerable(Of Department) = From d As Department In MyObject.Departments Where d.CompanyId = 1 Select d
 +
</pre>
 +
</code>
 +
 +
Of course, when factoring in joins (equivalent to inner joins in SQL) and group joins (equivalent to outer joins in SQL) the full power of Linq becomes obvious. The reduction of code duplication is immense, and as Linq can be applied across technologies (Linq-to-SQL, Linq-To-Xml etc) it becomes clear that the origin of the data is less significant than the data itself.
    
[[Category:Computers]]
 
[[Category:Computers]]
57

edits

Navigation menu