LINQ

linq

Over last few months I wrote few blogs about different languages and their specific features. Today, we will discuss about inserting or modifying data in database which is an important part of business in various fields. For modifying data firstly we require to connect with database. In C#, you can create connection with the help of ADO.Net, LINQ and OLEDBC etc. But for now we will only discuss about LINQ which stands for .Net Language Integrated Language, Which is a query operators used in web pages to retrieve and modify data either from database or with XML file. It applies the principle of Object Oriented Programming to relational data. In Relational data like Select, Join, Group, Partition, Set Operation are implemented in LINQ.

LINQ offers compact, Expressive and intangible syntax for manipulating data. It uses SQL like syntax to make query expression. It Provide two sets of Standard query operator on objects of type IEnumerable<T> and other set operate on object type IQueryable<T>. LINQ enables you to communicate with different data source.

Sample LINQ Query:

// Obtain the data source

string[] ProgLang = {"C", "Pearl", "Python"}; //String Array

// Create the Query

IEnumerable<string> lang =

from l in musicalArtists

where l.StartsWith("P")

select l;

// Execute the Query

foreach (var artist in lang)

{

Console.WriteLine(l);

}

 

In following program, Query expressions consist of three clauses that are from, where and select.
The query variable itself doesn’t take any action and without returning data. It stores the information that is required to produce the results for when the query is executed.

 

Types of LINQ are:

 

  • LINQ to Object: Through LINQ to object we can use Query Object in collection and can access in memory data structure using LINQ.
  • LINQ to XML: It provides in memory document modification facilities in DOM and LINQ Query Expression.
  • LINQ to Dataset: It makes easier and faster to query over data cached in dataset object.
  • LINQ to SQL: It conducts queries against relational database through LINQ to SQL database model and related data context.
  • LINQ to Entities: It converts LINQ queries to command tree queries, execute the queries against entity framework and return object that can be used by both entity framework and LINQ.

 

For more info : cpd-india

Batches: Regular & Weekends for Working Profession

For FREE DEMO CLASS CALL – 011-65164822 / 91- 8860352748

CPD Technologies Block C 9/8, Sector – 7, Rohini, Delhi – 110085, India Landmark: Near Rohini East Metro Station, Opposite Metro Pillar No-397

Website :- www.cpd-india.com

Email :- support@cpd-india.com

Your email address will not be published. Required fields are marked *

Contact CPD Technologies