[023]◀▶C # Learning (10)-generic & LINQ

Source: Internet
Author: User

LINQ (Language integration query)

Bytes --------------------------------------------------------------------------------------------------------------

When there are too many threads, there are too many threads.
Please refer to the following link for more information: when there are too many threads, there are too many threads, too many threads.
When there are too many threads, there are too many threads.

● · ● LINQ (Language integration query ):

1. Language Integrated Query (LINQ) is a set of functions introduced in Visual Studio 2008. It provides powerful query functions for C # and Visual Basic syntax. LINQ
A standard and easy-to-learn Data Query and update mode is introduced. This technology can be extended to support almost any type of data storage. Visual Studio includes
Provides program assembly. With these assembly, you can use LINQ for. NET Framework collection, SQL Server database, ADO. NET
Datasets and XML documents.

2. Language integration query (LINQ) is an innovative feature introduced in Visual Studio 2008 and. NET Framework 3.5. It builds a bridge between the object field and the data field.

Example: Generic

        private void button1_Click(object sender, EventArgs e)
{
int[] scores = new int[] { 88, 89, 100, 51, 23, 92, 81, 60 };
IEnumerable<int> scoreQuery =
from score in scores
where score > 70
select score;
foreach (int i in scoreQuery)
{
richTextBox1.Text += i + " ";
}
}

Example: var keyword

 

        private void button2_Click(object sender, EventArgs e)
{
int[] numbers = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
var numQuery =
from num in numbers
where (num % 2) == 0
select num;
foreach (int num in numQuery)
{
richTextBox1.Text += "\t" + num.ToString() + "\n";
}
}

 

Bytes --------------------------------------------------------------------------------------------------------------

When there are too many threads, there are too many threads.
Please refer to the following link for more information: when there are too many threads, there are too many threads, too many threads.
When there are too many threads, there are too many threads.

● · ● LINQ query expression:


1. language integration query (LINQ) is the name of a group of technologies. These technologies are built on integrating the query function directly into the C # Language (and Visual Basic and any other possible.. NET Language. With the help of LINQ, queries are now structured in high-level languages, such as similar methods, events, and so on.

2. the query expression must start with the from clause and end with the select or group clause. Between the first from clause and the last select or group clause, a query expression can contain one or more of the following optional clauses: where, orderby, join, let, or even additional from clause. You can also use the into keyword to make the results of join or group Clauses Act as the source for adding query clauses to the same query expression.

 

int highScoreCount =
(from score in scores
where score > 80
select score)
.Count();


Bytes --------------------------------------------------------------------------------------------------------------

When there are too many threads, there are too many threads.
Please refer to the following link for more information: when there are too many threads, there are too many threads, too many threads.
When there are too many threads, there are too many threads.

● · ● LINQ to SQL:



1.

LINQ to SQL is a component. NET Framework version 3.5 that provides a run-time infrastructure for managing relational data as objects. "> LINQ to SQL is. NET Framework 3.5 is a component that provides the runtime infrastructure for object management.

2. creation process on Visual Studio 2010: Right-click the project, add a new item, and add a new item to the SQL

 

3. Pull the database table to DataClass2.dbml to establish a connection!

 

Import data:

OpenFileDialog ofd = new OpenFileDialog ();
If (ofd. ShowDialog ()! = DialogResult. OK) // select the file to import data
Return;
DataClasses1DataContext ctx = new DataClasses1DataContext ();
Using (StreamReader reader = new StreamReader (File. OpenRead (ofd. FileName), System. Text. Encoding. Default ))
{
String str;
While (str = reader. ReadLine ())! = Null)
{
IdentityCard Card = new IdentityCard (); // create a Card instance and add data
String [] strs = str. Split ('\ t ');
String no = strs [1];
String address = strs [2];
Card. No = no;
Card. Address = address;
Ctx. IdentityCard. InsertOnSubmit (Card); // submit data
Ctx. SubmitChanges ();
}
}


 

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.