YPTHDataContext ypth = new YPTHDataContext();
int[] arr1 = { 32, 43, 43, 54, 65, 76, 56, 434 };
int[] arr2 = { 3, 34, 23, 54, 65, 76, 65, 29, 402, 45 };
/**数据组内部连接***/
var query1 = from val in arr1 join val2 in arr2 on val equals val2 select new { num1 = val, num2 = val2 };
foreach (var item in query1)
{
Console.WriteLine(item);
}
Console.WriteLine("************************************************");
var query2 = from val in arr1 join val2 in arr2 on val % 3 equals val2 % 3 select new { num1 = val, num2 = val2 };
foreach (var item in query2)
{
Console.WriteLine(item);
}
/**表格的内部连接**/
var query4 = from val in ypth.T_User join val2 in ypth.T_userInfo on val.ID equals val2.id select new { num1 = val.ID, num2 = val2.realName };
foreach (var item in query4)
{
Console.WriteLine(item);
}
LINQ之JOIN的内部联接
最新推荐文章于 2022-12-20 16:59:50 发布