SlideShare a Scribd company logo
1 of 22
Download to read offline
LINQ!LINQ!LINQ!
               ∼非.NETerに送るLINQの紹介∼



                     大橋 宏章




12年7月21日土曜日
Profile

              • LAMPな会社に迷い込んだ.C#er
              • Twitter:@nal_6295
              • http://blog.nal-6295.biz


12年7月21日土曜日
Agenda
              •   LINQって何?

              •   LINQ が扱えるものって何?

              •   LINQでコレクションを操作

              •   LINQで複数のコレクションを操作

              •   LINQ to X
              •   .NET以外のLINQ実装って無いわけ?


12年7月21日土曜日
LINQって何?


              聞く前に「LINQ」を検索条件にbingれ




12年7月21日土曜日
ということでbingってみました




   ついでにぐぐってみました




12年7月21日土曜日
もう少し下に伸ばしてみると・・・




12年7月21日土曜日
LINQって何?

              • LINQはLanguage INtegrated Queryの略称
                でSQLみたいな問い合わせ構文を言語
                に取り込んだもの

              • 日本語では「統合言語クエリ」

12年7月21日土曜日
LINQが扱えるものって何?
              •   主に以下の3つが基本

                  •   コレクション(List、DictionaryなどIEnumerableを実装しているもの)
                      を扱う事が可能 (LINQ to Object)

                  •   XML(System.XML.XPath名前空間を利用)を扱う事が可能(LINQ to
                      XML)

                  •   RDBを扱う事が可能(LINQ to SQL,LINQ to EF)

              •   Reactive Extentionsというプラグインを入れるとIObservableを実装して
                  いるものもLINQで扱えるようになり、時間軸やイベントなども操作
                  できるようになる。




12年7月21日土曜日
LINQでコレクションを操作

              以下のように用意しておいた在庫のリストの
              中から数量が10より大きくて、30で割った
              時の余りが無いものを抽出して出力します。




12年7月21日土曜日
まずはLINQを使わないで




              まぁ、よくある感じのコード


12年7月21日土曜日
LINQで書くと・・・



              メソッドチェーンでの表現も可能




12年7月21日土曜日
LINQで複数のコレクションを操作


              以下のように用意しておいた在庫のリスト
              と商品のリストを結合して、商品番号、商
              品名、数量、LOTNOを出力します。




12年7月21日土曜日
まずはLINQを使わないで




              foreachがネストしてますね




12年7月21日土曜日
LINQで書くと・・・




12年7月21日土曜日
せっかくなので商品別に在庫を集計して
              表示してみましょう。

              在庫が存在しないデータも0で表示する
              事にしましょう。




12年7月21日土曜日
まずはLINQを使わないで




          その場で出力しているから良いものの、新しいコレクションを作ってそれを
              使って処理をするような場合、もう少しめんどくさいコードに・・・




12年7月21日土曜日
LINQで書くと・・・




               一貫して欲しい出力をクエリ定義するだけで良い




12年7月21日土曜日
LINQで書くと・・・
              • 消失するループ
              • 消失するネスト
              • 問い合わせの定義と、問い合わせ結果
               を利用するコードの分離

              • 常にタイプセーフ
12年7月21日土曜日
LINQ to X
              • LINQが扱えるものは実は拡張可能
              • LINQ to Oracle,LINQ to WMI,LINQ to
                Active Directory,LINQ to Twitter,LINQ to
                mongoDB等々・・・いろんな拡張が実装
                されている

              • Query Providerを実装する事で拡張できる

12年7月21日土曜日
LINQ to Twitterをためしてみよう




              デモ




12年7月21日土曜日
.NET以外のLINQ実装ってないわけ?

              •   linq.js
                  •   JavaScriptでLINQによるコレクション操作が
                      可能です。

                  •   http://linqjs.codeplex.com/
              •   PHPLinq
                  •   PHPにもLINQの実装がありました。

                  •   http://phplinq.codeplex.com/


12年7月21日土曜日
まとめ


              C#erもJSerもPHPerも楽しいLINQ生活を
              送りましょう。




12年7月21日土曜日

More Related Content

Recently uploaded

知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptxsn679259
 
Utilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsUtilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsWSO2
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルCRI Japan, Inc.
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Gamesatsushi061452
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...Toru Tamaki
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NTT DATA Technology & Innovation
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイスCRI Japan, Inc.
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video UnderstandingToru Tamaki
 
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Hiroshi Tomioka
 

Recently uploaded (12)

知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
 
Utilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsUtilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native Integrations
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
 
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

非.NETerに向けたLINQの紹介

  • 1. LINQ!LINQ!LINQ! ∼非.NETerに送るLINQの紹介∼ 大橋 宏章 12年7月21日土曜日
  • 2. Profile • LAMPな会社に迷い込んだ.C#er • Twitter:@nal_6295 • http://blog.nal-6295.biz 12年7月21日土曜日
  • 3. Agenda • LINQって何? • LINQ が扱えるものって何? • LINQでコレクションを操作 • LINQで複数のコレクションを操作 • LINQ to X • .NET以外のLINQ実装って無いわけ? 12年7月21日土曜日
  • 4. LINQって何? 聞く前に「LINQ」を検索条件にbingれ 12年7月21日土曜日
  • 5. ということでbingってみました ついでにぐぐってみました 12年7月21日土曜日
  • 7. LINQって何? • LINQはLanguage INtegrated Queryの略称 でSQLみたいな問い合わせ構文を言語 に取り込んだもの • 日本語では「統合言語クエリ」 12年7月21日土曜日
  • 8. LINQが扱えるものって何? • 主に以下の3つが基本 • コレクション(List、DictionaryなどIEnumerableを実装しているもの) を扱う事が可能 (LINQ to Object) • XML(System.XML.XPath名前空間を利用)を扱う事が可能(LINQ to XML) • RDBを扱う事が可能(LINQ to SQL,LINQ to EF) • Reactive Extentionsというプラグインを入れるとIObservableを実装して いるものもLINQで扱えるようになり、時間軸やイベントなども操作 できるようになる。 12年7月21日土曜日
  • 9. LINQでコレクションを操作 以下のように用意しておいた在庫のリストの 中から数量が10より大きくて、30で割った 時の余りが無いものを抽出して出力します。 12年7月21日土曜日
  • 10. まずはLINQを使わないで まぁ、よくある感じのコード 12年7月21日土曜日
  • 11. LINQで書くと・・・ メソッドチェーンでの表現も可能 12年7月21日土曜日
  • 12. LINQで複数のコレクションを操作 以下のように用意しておいた在庫のリスト と商品のリストを結合して、商品番号、商 品名、数量、LOTNOを出力します。 12年7月21日土曜日
  • 13. まずはLINQを使わないで foreachがネストしてますね 12年7月21日土曜日
  • 15. せっかくなので商品別に在庫を集計して 表示してみましょう。 在庫が存在しないデータも0で表示する 事にしましょう。 12年7月21日土曜日
  • 16. まずはLINQを使わないで その場で出力しているから良いものの、新しいコレクションを作ってそれを 使って処理をするような場合、もう少しめんどくさいコードに・・・ 12年7月21日土曜日
  • 17. LINQで書くと・・・ 一貫して欲しい出力をクエリ定義するだけで良い 12年7月21日土曜日
  • 18. LINQで書くと・・・ • 消失するループ • 消失するネスト • 問い合わせの定義と、問い合わせ結果 を利用するコードの分離 • 常にタイプセーフ 12年7月21日土曜日
  • 19. LINQ to X • LINQが扱えるものは実は拡張可能 • LINQ to Oracle,LINQ to WMI,LINQ to Active Directory,LINQ to Twitter,LINQ to mongoDB等々・・・いろんな拡張が実装 されている • Query Providerを実装する事で拡張できる 12年7月21日土曜日
  • 20. LINQ to Twitterをためしてみよう デモ 12年7月21日土曜日
  • 21. .NET以外のLINQ実装ってないわけ? • linq.js • JavaScriptでLINQによるコレクション操作が 可能です。 • http://linqjs.codeplex.com/ • PHPLinq • PHPにもLINQの実装がありました。 • http://phplinq.codeplex.com/ 12年7月21日土曜日
  • 22. まとめ C#erもJSerもPHPerも楽しいLINQ生活を 送りましょう。 12年7月21日土曜日