Microsoft Language Integrated Query (LINQ) For Sql Ie NEQ To SQL

965 Words2 Pages

Microsoft Language Integrated Query (LINQ) for SQL ie LINQ to SQL

Introduction:

This article is about LINQ (Language Integrated Query) which is one of the most entertaining concept and feature in .NET programming. LINQ makes the querying of data a unique programming concept in .NET. Querying of data can be taken from XML (LINQ to XML), database (LINQ enabled ADO.NET, LINQ to SQL, LINQ to Dataset, LINQ to Entities) and Object (LINQ to Objects).

LINQ can easily and highly extensible and allow developers to build custom data providers to access data. Eg. LINQ to Amazon, LINQ to Excel, LINQ to Javascript etc.

The scope of this article is narrowed to LINQ to SQL. This is the use of LINQ to access data from database particularly Microsft SQL Server.

Why LINQ

Many developers must use two or more programming languages: a high-level language for the business logic and presentation layers (such as Visual C# or Visual Basic), and a query language to interact with the database (such as Transact-SQL, P-SQL).

This requires the developer to be proficient in several languages to be effective. For example, an application that uses a data access API to execute a query against a database specifies the query as a string literal by using quotation marks eg “select * from product”. This query string is un-readable to the compiler and is not checked for errors, such as invalid syntax or whether the columns or rows it references actually exist in the database table. There is no type checking of the query parameters and no IntelliSense support is available, either.

Language-Integrated Query (LINQ) enables developers to form set-based queries in their application code, without having to use a separate query language. You can write LINQ queries ag...

... middle of paper ...

...broutines and can be single-line or multi-line. You can pass values from the current scope to a lambda expression.(Definition from Microsoft)
The following example is a lambda expression that increments its argument and returns the value. The example shows both the single-line and multi-line lambda expression syntax for a function.

Example from Microsoft(http://msdn.microsoft.com/en-us/library/bb531253.aspx)

Conclusion:

This is a brief introduction to Microsoft LINQ specifically LINQ to SQL. For further reading please visit the links below to explore the power of LINQ;
• http://msdn.microsoft.com/en-us/library/bb385100.aspx
• http://msdn.microsoft.com/en-us/vstudio/bb688085.aspx
• http://en.wikipedia.org/wiki/Language_Integrated_Query
• http://www.codeproject.com/Articles/24448/LINQ-to-SQL-Samples
• http://codesamplez.com/database/linq-to-sql-c-sharp-tutorial

More about Microsoft Language Integrated Query (LINQ) For Sql Ie NEQ To SQL

Open Document