Linq into query continuation clause

grammar

into identifier

effect

Accept part of the result of the query and give it a name
The result can be used as a collection to continue the query

case

var student2 = new[]
{
    
    
    new {
    
    Name="小黑",ID=1},
    new {
    
    Name="小宝",ID=2},
};
var student3 = new[]
{
    
    
    new {
    
    Class="语文",ID=1},
    new {
    
    Class="数学",ID=1},
    new {
    
    Class="英语",ID=0}
};
var result2 = from s in student2
              join s2 in student3 on s.ID equals s2.ID
              into students//students是student3中符合联结条件的集合 不包含studnet2中的元素
              from s3 in students
              select s3.Class;
foreach (var item in result2)
{
    
    
    Debug.Log(item);
}

student2

Name ID
little black 1
little treasure 2

student3

Class ID
language 1
math 1
English 0

after linking

Name ID Class
little black 1 math
little black 1 language

query continuation results students

ID Class
language 1
math 1

Guess you like

Origin blog.csdn.net/weixin_43796392/article/details/122545955