当前位置:网站首页>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);
边栏推荐
- Experience of epidemic prevention and control, home office and online teaching | community essay solicitation
- How to open a stock account? Is it safe to open a mobile account?
- 元宇宙的生态圈
- 2个NPN三极管组成的恒流电路
- 02 common codes for Epicor secondary development
- 常用的软件测试工具清单,请查收。
- Unity C # e-learning (VI) -- FTP (I)
- 1-6搭建Win7虚拟机环境
- Specific list of regular and safe domestic stock trading account opening
- Notes on BGP part of CCNP
猜你喜欢

转行软件测试2年了,给还在犹豫的女生一点建议

Please run IDA with elevated permissons for local debugging.

谈谈飞书对开发工作的优势 | 社区征文

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

Test / development programmers, 30, do you feel confused? And where to go

leetcode:2104. Subarray range and

一线城市软件测试工资——你拖后腿了吗

【Proteus仿真】Arduino UNO+数码管显示4x4键盘矩阵按键

当他们在私域里,掌握了分寸感

数据库系统概论必背知识
随机推荐
Chinese address and English address
Some Modest Advice for Graduate Students - by Stephen C. Stearns, Ph.D.
云原生数据库VS传统数据库
Build and train your own dataset for pig face recognition
An Chaoyun: "one cloud with multiple cores" supports the implementation of the national information innovation government cloud
O (log (min (m, n))
【Proteus仿真】Arduino UNO+继电器控制照明设备
Integration of metersphere open source continuous testing platform and Alibaba cloud cloud cloud efficient Devops
Android物联网应用程序开发(智慧园区)—— 设置传感器阈值对话框界面
Combined with practice, you will understand redis persistence
FTP协议讲解
[leetcode] 11. Container with the most water
困牛排序(寒假每日一题 40)
疫情防控,居家办公,网上授课之心得 | 社区征文
Use of hashcat
Application session coverage solutions with different ports on the same server
罗德与施瓦茨与中关村泛联院合作开展6G技术研究与早期验证
指南针靠谱吗?开证券账户安全吗?
Preg in PHP_ How to replace variable data
Please run IDA with elevated permissons for local debugging.