当前位置:网站首页>LINQ query (3)
LINQ query (3)
2022-06-25 02:11:00 【flysh05】
Internal connection Join
Check separately , Query the data and connect
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);
Merge together , Direct internal connection
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);
Use method connection
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);
边栏推荐
- 文件系统 -- 磁盘基础知识和FAT32文件系统详细介绍
- 内网学习笔记(7)
- 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
- Award winning interface control development kit devaxpress v22.1 officially announced
- Longest continuous sequence [diffusion method + space for time]
- 同花顺是正规平台吗?同花顺开户安全吗
- String common methods
- 做软件安全测试的作用,如何寻找软件安全测试公司出具报告?
- AssertionError: CUDA unavailable, invalid device 0 requested
- Explanation of FTP protocol
猜你喜欢

創新藥二級市場審餅疲勞:三期臨床成功、產品獲批也不管用了

Experience of epidemic prevention and control, home office and online teaching | community essay solicitation

Chinese address and English address

罗德与施瓦茨与中关村泛联院合作开展6G技术研究与早期验证

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

【直播回顾】战码先锋第七期:三方应用开发者如何为开源做贡献

Fatigue liée à l'examen du marché secondaire des médicaments innovants: succès clinique de la phase III et approbation du produit

Constant current circuit composed of 2 NPN triodes

EasyCVR国标协议接入的通道,在线通道部分播放异常是什么原因?

创新药二级市场审饼疲劳:三期临床成功、产品获批也不管用了
随机推荐
Chinese address and English address
股票开账户如何优惠开户?手机开户是安全么?
EasyCVR平台EHOME协议接入,视频播放出现断流是什么原因?
Hashcat 的使用
Basic layout -qhboxlayout class, qvboxlayout class, qgridlayout class
After integrating the aurora push plug-in in the uni app, the real machine debugging prompts "the currently running base does not contain the native plug-in [jg-jpush]..." Solutions to problems
MOS管相关知识
DataEase模板市场正式发布
监听 Markdown 文件并热更新 Next.js 页面
Four characteristics of actual attack and defense drill
Is the compass reliable? Is it safe to open a securities account?
当他们在私域里,掌握了分寸感
Half of the year has passed. How many flags have been achieved at the end of the year?
门店无线音箱造假?索尼回应:产品预留了有线连接接口 复杂场景下可以使用
jwt
FTP协议讲解
如何通过EasyCVR接口监测日志观察平台拉流情况?
都2022年了,你还不了解什么是性能测试?
MeterSphere開源持續測試平臺與阿裏雲雲效DevOps的集成
MeterSphere开源持续测试平台与阿里云云效DevOps的集成