C # LINQ acquaintance

What is LINQ

For a long time, the development community form the following pattern:

1, object-oriented data access with two areas of long division, fragmentation.

2, the data types of the programming language and the database data type is formed of two different systems, for example:

  C # string represented by the string data type.

  SQL string represented by NVarchar / Varchar / Char data type.

3, SQL coding experience behind

  IntelliSense no effect.

  There is no strong type checking and type in the strict sense.

4, SQL, and XML has its own query language, and the object is not their own query language.

The above description of the problem, can be solved using LINQ, LINQ then what is it?

LINQ (Language Integrated Query) that is language-integrated query.

LINQ is a set of language features and API, allows you to use a unified approach to the preparation of various queries. For storing and retrieving data from different data sources, thereby eliminating the mismatch between the programming language and the database, and provide a single query interface for different types of data sources.

Always use LINQ object, so you can use the same query syntax to query and transform XML, collections of objects, SQL databases, ADO.NET datasets, and any other available data provider for LINQ format.

LINQ mainly contains the following three parts:

1, is mainly responsible for LINQ to Objects query object.

2, LINQ to XML is responsible for XML query.

3, LINQ to ADO.NET mainly responsible for querying the database.

  LINQ to SQL

  LINQ to DataSet

  LINQ to Entities

Three, LINQ advantage

1, familiar language: developers do not have to learn a new language for each type of data source or data format.

2, fewer coding: comparing a conventional manner, the LINQ reduces the amount of code to be written.

3, readable: LINQ to increase the readability of the code, so other developers can easily understand and maintain.

4, a standardized query: LINQ can use the same syntax of the query multiple data sources.

5, type checking: the program will provide type checking at compile time.

6, IntelliSense Tip: LINQ provides intellisense prompt a generic collection.

7, shaping data: LINQ data may be retrieved in different shapes.

Guess you like

Origin www.cnblogs.com/1016391912pm/p/11620986.html