using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 用Join子句进行分组联接
{
class Program
{
static void Main(string[] args)
{
int[] intAry1 = { , , , , , };
int[] intAry2 = { , , , , , , };
var query1 =
from val1 in intAry1 //在数组intAry1中取到val1
join val2 in intAry2 //同时在数组intAry2中取到val2
on val1% equals val2% into val2Grp
//val2Grp中的数据是val1和val2的两个对象,而不是记录
where val2Grp.Count()!=
//new { VAL1 = val1, VAL2GRP = val2Grp产生一个新类型
select (new { VAL1 = val1, VAL2GRP = val2Grp });
//遍历新的数据类型
foreach(var item in query1)
{
foreach(int item1 in item.VAL2GRP)
{
Console.WriteLine(item.VAL1+" "+item1.ToString());
}
}
System.Console.ReadKey();
}
}
}