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 );