Data access by using LINQ and. NET, and data access by using LINQ. NET
. NET data access
In. NET, there are roughly three layers for data access: data access layer, memory dataset, and business logic layer. Data layer, including XML configuration files and some common databases (using SQL statements); Memory datasets, mainly DataSet datasets, including Datatable in DataSet, dataRow and DataColumn are available in able. Data in a specific dataset is generally accessed through DataRow. the business logic layer is a generic set of commonly used objects.
Basics
It corresponds to three layers of Data Access: data access layer, using LINQ to XML, LINQ to SQL, and LINQ to Entities; In-memory DataSet, using LINQ to DataSet; business logic layer, use LINQ to Object.
In retrospect, we often need to use filtering, grouping, and conversion to extract information from the object set to get the correct output. We may use for and foreach to traverse the information cyclically, check each object according to some conditions, and operate or save the object. These codes are imperative codes.
Currently, using LINQ to operate on object sets is declarative code. This type of code is highly efficient in development and readable. At the business logic layer, using LINQ to Object can improve execution efficiency. The LINQ language is similar to SQL. It has from, where, select, join, group by, and order by statements.
The general process used by LINQ. Generally, the operation is a generic set of objects. After using the frequently-used LINQ statements, the IEnumerable generic set is extracted for the foreach iterator to traverse.
Not complete .......