当前位置:网站首页>LINQ 查询(3)
LINQ 查询(3)
2022-06-24 22:31:00 【flysh05】
内连接 Join
分别查询,查询数据再做连接
var racers = from r in Formula1.GetChampions()
from y in r.Years
select new
{
Year = y,
Name = r.FirstName + " " + r.LastName
};
var teams = from t in Formula1.GetConstructorChampions()
from y in t.Years
select new
{
Year = y,
Name = t.Name
};
var racersAndTeams = (from r in racers
join t in teams on r.Year equals t.Year
select new
{
r.Year,
Champion = r.Name,
Constructor = t.Name
}).Take(10);
合并在一起,直击内连接
var racersAndTeams = (from r in
from r1 in Formula1.GetChampions()
from yr in r1.Years
select new
{
Year = yr,
Name = r1.FirstName + " " + r1.LastName
}
join t in
from t1 in Formula1.GetConstructorChampions()
from yt in t1.Years
select new
{
Year = yt,
Name = t1.Name
}
on r.Year equals t.Year
orderby t.Year
select new
{
Year = r.Year,
Racer = r.Name,
Team = t.Name
}).Take(10);
使用方法连接
var racers = Formula1.GetChampions()
.SelectMany(r => r.Years, (r1, year) =>
new
{
Year = year,
Name = $"{
r1.FirstName} {
r1.LastName}"
});
var teams = Formula1.GetConstructorChampions()
.SelectMany(t => t.Years, (t, year) =>
new
{
Year = year,
Name = t.Name
});
var racersAndTeams = racers.Join(teams,
r => r.Year,
t => t.Year,
(r, t) =>
new
{
Year = r.Year,
Champion = r.Name,
Constructor = t.Name
}).OrderBy(item => item.Year).Take(10);
边栏推荐
- Unity C # e-learning (VI) -- FTP (II)
- Longest continuous sequence [diffusion method + space for time]
- Award winning interface control development kit devaxpress v22.1 officially announced
- Smartctl 打开设备遇到 Permission denied 问题排查过程记录
- 【第26天】给定 n 个元素的升序数组nums,求实现一个函数在nums中寻找target的下标 | 初识二分查找
- Numerical scheme simulation of forward stochastic differential equations with Markov Switching
- 文件系统 -- 磁盘基础知识和FAT32文件系统详细介绍
- Multimodal emotion recognition_ Research on emotion recognition based on multimodal fusion
- EasyCVR国标协议接入的通道,在线通道部分播放异常是什么原因?
- Logminer database log mining
猜你喜欢

Fake wireless speakers in stores? Sony responded: the product has reserved a wired connection interface, which can be used in complex scenarios

元宇宙的生态圈

JS array object to object

What is the reason for the disconnection of video playback due to the EHOME protocol access of easycvr platform?

Abnova CSV magnetic beads description in Chinese and English

How to quickly familiarize yourself with the code when you join a new company?

常用的软件测试工具清单,请查收。

会自动化—10K,能做自动化—20K,你搞懂自动化测试没有?

测试/开发程序员,30而立,你是否觉得迷茫?又当何去何从......

Multi modal data can also be Mae? Berkeley & Google proposed m3ae to conduct Mae on image and text data! The optimal masking rate can reach 75%, significantly higher than 15% of Bert
随机推荐
Day 04 - file IO
保险APP适老化服务评测分析2022第06期
Google browser console F12 how to set the Chinese / English switching method, we must see the last!!!
MOS tube related knowledge
Investigation on key threats of cloud computing applications in 2022
write a number of lines to a new file in vim
进入阿里做测试员遥不可及?这里或许有你想要的答案
Hashcat 的使用
MCN机构遍地开花:博主和作者要谨慎签约、行业水很深
Abnova CSV magnetic beads description in Chinese and English
你知道你的ABC吗(春季每日一题 1)
What is the reason for the disconnection of video playback due to the EHOME protocol access of easycvr platform?
Search two-dimensional matrix [clever use of bisection + record solution different from inserting bisection]
How to open a stock account? Is it safe to open a mobile account?
Build and train your own dataset for pig face recognition
Preg in PHP_ How to replace variable data
Exploring the mystery of C language program -- C language program compilation and preprocessing
How to get the picture outside the chain - Netease photo album [easy to understand]
【移动端】手机界面的设计尺寸
O (log (min (m, n))