当前位置:网站首页>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);
边栏推荐
- Status quo analysis: how "one cloud and multi-core" can promote the rapid deployment of information innovation projects
- 【Proteus仿真】Arduino UNO+数码管显示4x4键盘矩阵按键
- JS array object to object
- 常用的软件测试工具清单,请查收。
- Sumati GameFi生态纵览,神奇世界中的元素设计
- Unity C # e-learning (VI) -- FTP (II)
- String common methods
- 股票开账户如何优惠开户?手机开户是安全么?
- 2022-06-24:golang选择题,以下golang代码输出什么?A:1;B:3;C:4;D:编译失败。 package main import ( “f
- Stocking but not completely stocking (daily question 2 in spring)
猜你喜欢

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

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

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

File system - basic knowledge of disk and detailed introduction to FAT32 file system

软件测试人员的7个等级,据说只有1%的人能做到级别7

MeterSphere開源持續測試平臺與阿裏雲雲效DevOps的集成

Day 04 - file IO

【FPGA】串口以命令控制温度采集

Please run IDA with elevated permissons for local debugging.

EasyCVR平台EHOME协议接入,视频播放出现断流是什么原因?
随机推荐
Test / development programmers, 30, do you feel confused? And where to go
How to open a stock account? Is it safe to open a mobile account?
linux上查看mysql的密码_Linux下MySQL忘记密码「建议收藏」
监听 Markdown 文件并热更新 Next.js 页面
【Proteus仿真】Arduino UNO+数码管显示4x4键盘矩阵按键
[day 26] given the ascending array nums of n elements, find a function to find the subscript of target in nums | learn binary search
Please run IDA with elevated permissons for local debugging.
Is GF futures safe? What do I need to open an account?
Is the compass reliable? Is it safe to open a securities account?
How to choose a regular and safe foreign exchange trading platform?
Exploring the mystery of C language program -- C language program compilation and preprocessing
Unity C # e-learning (VI) -- FTP (II)
内网学习笔记(6)
Investigation on key threats of cloud computing applications in 2022
左手梦想 右手责任 广汽本田不光关注销量 还有儿童安全
Dataease template market officially released
Notes on BGP part of CCNP
Deoxyribonuclease I instructions in Chinese and English
Rod and Schwartz cooperated with ZhongGuanCun pan Lianyuan Institute to carry out 6G technology research and early verification
Is CICC securities reliable? Is it safe to open a securities account?