C #4.0 new features (4) New LINQ Extension Method-zip ()
1. Introduction
The so-called zip (Chinese indicates a zipper) is to stitch two lists together like a zipper. There is a zip function in Python that can be used to conveniently merge two or more sets, for example:
Code highlighting produced by Actipro CodeHighlig
1 int[] numbers = {1,2,3,4 };2 string[] Words = {" One"," Both","three" };3 4 varNumbersandwords = numbers. Zip (words, (first, second) + First +" "+second);5 6 foreach(varIteminchnumbersandwords)7Console.WriteLine (item);The main reference of the few contentspublic static ienumerableParameters
First
Type:
system.collections.generic.ienumerabletfirst>
The first se
LINQ: getting started with LINQ (1)-Introduction to LINQ query and linq QueryGetting started with LINQ (1)-Introduction to LINQ Query
A query is an expression used to retrieve data from a data source. Over time, people have develo
LINQ: start to use LINQ (2)-Basic LINQ query operations, linq QueryGetting started with LINQ (2)-Basic LINQ query operations
The first step is to specify the data source. Like in most programming languages, variables must be decla
LINQ: start to use LINQ (3)-use LINQ for data conversion, and use linq for Data ConversionGetting started with LINQ (3)-using LINQ for Data Conversion
Language integration query (LINQ)
LINQ is a new thing, but from many articles and discussions, this concept is a bit chaotic. Therefore, we often see the following:
Only data tables and object attributes can be matched one by one in LINQ ......
LINQ Development Guide: map database fields in LINQ ......
In fact, the above two statements refer to the
LINQ is a new thing, but from many articles and discussions, the concept is a bit confusing. So we can often see this:
LINQ can only match data tables to entity attribute one by one ...
LINQ Development Guide: Database field mapping in LINQ ...
In fact, the above two sentences are all
only introduces several common query operators. In the subsequent chapters, I will discuss more operators in detail.
Blog series Navigation:
Blog navigation of the road to LINQ
Road 1 of LINQ: Introduction to LINQ
The path to LINQ 2: C #3.0 language functions (I)
The path to LIN
)
Road 15 to LINQ: Element Operators, set methods, and quantifiers of LINQ Operators
LINQ LINQ 16: Collection Operators, Zip Operators, conversion methods, and generator methods of LINQ Operators
X-DOM introduction to the road to
= q.todictionary (p = p.productid);foreach(intKeyinchQdictionary.keys) {Console. WriteLine (key);}Statement Description: This sample uses todictionary to directly evaluate the query and key expression direct key expressions as dictionaryAdo. NET and LINQ to SQLLINQ to SQL is based on the services provided by the ADO provider model. As a result, we were able to mix LINQ to SQL code with existing ADO-out app
Introduction to Query expressions (LINQ)
In the last two articles, I introduced the features and improvements of C #3.0 new language.ProgramIt provides us with great help. From the beginning of this article, we will start to discuss the LINQ.
LINQ is short for Language Integrated Query, which is integrated in. net.Programming Language. It has become an integra
Linq learning summary 1-refer to the detailed description of Linq technology, 1-linqKey points:1. The set of linq operations must implement the IEnumerable interface. Therefore, before 3.0, the set that implements this interface must be converted to a Linq-enabled set through the Cast or TypeOf method;
2. the query exp
Linq learning summary 1-refer to the detailed description of Linq technology, 1-linq
Two key points:
1. The set of linq operations must implement the IEnumerable interface. Therefore, before 3.0, the set that implements this interface must be converted to a Linq-enabled set
A more concise version will be published in the blog Hall (excluding the English version). I hope this article will help you!
Allowed to reprint, trouble to indicate the source: http://www.cnblogs.com/hanxianlongOriginal article:Http://weblogs.asp.net/scottgu/archive/2007/05/29/linq-to-sql-part-2-defining-our-data-model-classes.aspx
In Part 1 of my LINQ to SQL blog post series I discussed "What Is
LINQ to datasets require the use of System.Core.dll, System.Data.dll and System.Data.DataSetExtensions.dll, add references System.Data and System.Data.DataSetExtensions to the project.1. DataTable Read ListDataSet ds = new DataSet ();//Omit the DS's fill code datatable products = ds. tables["Product"];ienumerableDataSet ds = new DataSet ();//Omit the DS's fill code datatable products = ds. tables["Product"];var rows = products. AsEnumerable () . Se
db.Products where p.UnitsInStock
Statement Description: In this example, the direct key expression of the query and key expression is directly calculated as a Dictionary ADO. NET and LINQ to SQL
LINQ to SQL is based on the services provided by the ADO. NET provider program model. Therefore, we can mix the LINQ to SQL code with the existing ADO. NET applicati
LINQ: starts to use LINQ (4)-LINQ to query the type relation of the operation.Start to use LINQ (4)-the type Relationship of the LINQ query operation.
The data source, query itself, and query execution are strongly-typed. The types of variables in the query must be the same
Read the catalogue:
The main design model of 1.LINQ frame
1.1. Chained design mode (System logic is designed in a pipelined way)
1.2. Chained Query method (stepwise processing of each work point in a query expression)
Core design principle of 2.LINQ frame
2.1. Languages above the Managed language (LINQ query expressi
to the LINQ Query method syntax (Fluent Syntax), which provides a number of query methods, such as Aggregate/reduce, all, any, concat, contains, count, distinct, Each, elementat, except, A, groupBy, GroupJoin, intersect, join, last, Min/max, Argmin/argmax, by, reverse, Selec T map, SelectMany, single, Skip, Take, thenby/thenbydescending, ToArray, todictionary/tolookupdictionary, Union, Wheretrue/filter, zip
1. Create two Relational Tables, student and class tables. Students and course schedules, as shown in the example.
2. Create a form in vs2010.
And writeCodeAs follows:
Namespace Linqtest{ Public Partial Class Frmmanytomany: Form{ Internal Static String Sqlconstr = @" Data Source = localhost; initial catalog = lxpower; user = sa; Pwd = " ; Public Frmmanytomany (){Initializecomponent ();}
PrivateVoidFrmmanytomany_load (ObjectSender, eventargs E){Binddata ();}
Private Void
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.