Two common methods for. NET to access the database in C language:. net to access data

Source: Internet
Author: User

Two common methods for. NET to access the database in C language:. net to access data

1. directly use C # To operate the Database Class Library ADO. NET

ADO. NET uses the Connection object to connect to the database, and uses Command or DataAdapter

And return the execution result to DataReader or DataAdapter.

Then use the obtained DataReader or DataAdapter object to operate the data results.

Ii. Entity Framework

Entity Framework is an ORM Framework of Microsoft. Is to support data-oriented software development

Send applications. We generally use this function in combination with linq and lambda expressions.

ORM (Object Relational Mapping Object ing) refers to the Object model and

Data Structures of relational databases are converted to each other. (Mutual conversion between table entities and tables)

LINQ query: When we use linq to query, the definition will be adjusted to the Queryable class, that is

This class encapsulates all the query methods of linq and provides a set of query implementation IQueryable

Static Method of the data structure.

IQueryable, like IList, is a collection used to receive a group of data, IQeurable

(IQuerable) does not immediately create persistent data in the memory, only to traverse it (such as through

Foreach), convert it to List, and so on before loading data to the memory, it can achieve "deferred execution

Row. If the currently loaded object has an associated entity (associations), the associated entity can be

.

Ilist-the inheritance order is as follows:

Ilist-> ICollection-> IEnumerable

IEnumerable allows developers to define the implementation of the foreach statement function and supports non-generic method simplification.

Single Iteration

The same IQueryable inherits from the generic interface IEnumerable.

The Queryable class provides an extended basic query method: Where, Select

Select provides the following methods:

Public static IQueryable Select (this

IQueryable source, Expression>

Selector );

The method provided by where is as follows:

Public static IQueryable Where (this

IQueryable source, Expression>

Predicate );

Public static IQueryable Where (this

IQueryable source, Expression>

Predicate );

Related Article

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.