LINQ series: LINQ to ADO. NET Overview

Source: Internet
Author: User

LINQ to ADO includes two separate technologies: LINQ to DataSet and LINQ to SQL. Using LINQ to Datasets, you can perform rich and optimized queries against a dataset, and LINQ to SQL can directly query the SQL Server database schema.
LINQ providers that are implemented by LINQ to DataSet and LINQ to SQL can convert source data to a collection of IEnumerable-based objects.

1. LINQ to DataSet

The dataset is a key element of the disconnected programming model on which ADO is generated, and the LINQ to DataSet enables developers to build richer query functionality in the dataset by using the same query formulation mechanisms available from many other data sources.

Using LINQ to Datasets, you can query data that is cached in a DataSet object more quickly and easily. LINQ to datasets simplify queries by writing queries by using the programming language itself rather than by using a separate query language.

LINQ to datasets can also be used to query data that is merged from one or more data sources.

The LINQ to DataSet functionality is primarily exposed through extension methods in the DataRowExtensions and DataTableExtensions classes. The LINQ to DataSet is built on and used by the existing ADO 2.0 architecture and cannot be replaced by ADO 2.0 in the application code.

As soon as the dataset is populated, you can begin querying the DataSet object using the LINQ to DataSet. There are several ways to load data into a dataset, such as using the DataAdapter class or LINQ to SQL. After the data is loaded into the DataSet object, you can begin querying the data.
Using LINQ to Datasets to express queries is similar to using language-integrated Query (LINQ) for other LINQ-enabled data sources.
LINQ queries can be executed against a single table in a DataSet, or multiple tables by using the Join and GroupJoin standard query operators.
Enables LINQ queries to be executed on typed and untyped DataSet objects. If the schema of the dataset is known at the time of application design, a typed dataset is recommended. In a typed DataSet, tables and rows have typed members for each column, making the query simpler and more readable.
In addition to the standard query operators implemented in System.Core.dll, the LINQ to DataSet adds a number of dataset-specific extensions that make it easier to query a set of DataRow objects. These DataSet extensions include operators for comparing row sequences and methods for accessing the column values of a DataRow.

2. LINQ to SQL

LINQ to SQL is suitable for development that does not require mapping to a conceptual model, and by using LINQ to SQL you can directly use the LINQ programming model directly on an existing database schema. LINQ to SQL can generate a representation of data. NETFramework class. These generated classes map directly to database tables, views, stored procedures, and user-defined functions, without mapping to the conceptual data model. When using LINQ to SQL, in addition to other data sources, such as XML, you can write code directly to the storage schema using the same LINQ programming patterns as memory collections and datasets.

LINQ series: LINQ to ADO. NET Overview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.