Tuesday, 8 February 2022

What is LINQ?

LINQ (Language Integrated Query) is uniform query syntax in C# and VB.NET to retrieve data from different sources and formats. Language Integrated means it is a part of language. 

SQL is a Structured Query Language used to save and retrieve data from a database. In the same way, LINQ is a structured query syntax built in C# and VB.NET to retrieve data from different types of data sources such as collections, ADO.Net DataSet, XML Docs, web service and MS SQL Server and other databases.

  • LINQ stands for Language Integrated Query. 
  • LINQ is developed by Microsoft and is available in System.Linq namespace.
  • LINQ is uniform query syntax which can be applied on different data source. 
  • LINQ offers a compact, expressive, and intelligible syntax for manipulating data.
  •  LINQ was introduced in .Net framework 3.5 and C# 3.0.
  • LINQ queries return results as objects.

LINQ
EXAMPLE OF LINQ QUERY

using System;
using System.Linq;

public class Program
{
public static void Main()
{
// Data source
string[] names = {"Harry", "John", "Peter"};
        
// LINQ Query 
                var myLinqQuery =  from name in names
                               where name.Contains('r')
                        select name;
        
// Query execution
                foreach (var name in myLinqQuery)
                    Console.Write(name + " ");
  }
}


0 comments:

Post a Comment

Please do not enter any spam link in the message box.