C # sixth time job

Source: Internet
Author: User

In this class, we mainly study. NET,LINQ and XML

The teacher introduced US first. NET Framework, that is, by compiler C # code into CIL (Common intermediate language) and then into the CLR (Common Language Runtime).

After that, the teacher explained to us the LINQ (language-integrated query), which is the language integrated query, which is the bridge of the connection program and the database, has the following characteristics:

1. Programmers perform every day are finding and retrieving objects in memory, a database, or an XML file.

2. SQL can only search relational database, not object-oriented languages.

3. LINQ is a bridge over object-oriented languages and relational database.

4. LINQ is Sql-like, and remove the distinctions among searching an in-memory data collection, a database, or an XML docum Ent.

Then I tried myself to define and run a query

which

ienumerable<customer> result = from Customer in Customers

where customer. FirstName = = "Donna"

Select customer;

is a LINQ Query that can be seen as three parts:

1. FROM clause (Specify range variable and data source customers)

2. Filtering (filter, where)

3. Projection (map, select)

is also the declaration and initialization of a query expression does not actually execute the example of the query, and

foreach (Customer customer in result)

{

Console.WriteLine (Customer. ToString ());

}

is a LINQ to query is executed, or evaluated, when you iterate through the query result example, both of which belong to deferred query Evaluation.

Of course deferred Query evaluation also has some other content:

1. If The data source has changed between executions, the result would be different. It's desired in the most situation.

2. If you want to cache the result so that it can processed later without have to reexecute the query and you can call E Ither the ToList () or the ToArray () method to save a copy of the result.

So I tried the ToList statement

After that we learned LINQ Operations:join queries, grouping, aggregation, and sorting.

where LINQ's JOIN clause is a data source that is connected to another data source, the result is returned only if the object that satisfies the join condition exists in all the data sources.

Here are the programs that I applied join to connect customer and address together

Then we learned the group query, and here is my query code with name as the keyword

C # sixth time job

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.