﻿
{"id":663,"date":"2012-05-24T13:11:30","date_gmt":"2012-05-24T13:11:30","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=663"},"modified":"2012-05-24T13:11:30","modified_gmt":"2012-05-24T13:11:30","slug":"linq-to-sql-join","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/linq-to-sql-join\/","title":{"rendered":"Linq To Sql &#8211; JOIN"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Linq To Sql&#8217;de Join i\u015flemleri nas\u0131l yap\u0131l\u0131r onu inceleyelim.<br \/>\n<!--more--><br \/>\nHemen bir \u00f6rnekle izah etmeye \u00e7al\u0131\u015fal\u0131m.<br \/>\n\u00d6nceki yaz\u0131lar\u0131mda haz\u0131rlad\u0131\u011f\u0131m Northwind.dbml dosyas\u0131n\u0131 kullanaca\u011f\u0131m.<br \/>\n&#8211;Beverages kategorisindeki \u00fcr\u00fcnler hangileridir ?<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            NorthwindDataContext Northwind = new NorthwindDataContext();\r\n            var Sonuc = from kategori in Northwind.Kategorilers\r\n                        join urun in Northwind.Urunlers on kategori.KategoriID equals urun.KategoriID\r\n                        where kategori.KategoriAdi == &quot;Beverages&quot;\r\n                        select new\r\n                        {\r\n                            Urun = urun.UrunAdi\r\n                        };\r\n            foreach (var item in Sonuc)\r\n            {\r\n                listBox1.Items.Add(item.Urun);\r\n            }\r\n<\/pre>\n<p>&#8220;join&#8221; anahtar s\u00f6zc\u00fc\u011f\u00fcnden sonraki parametre &#8220;Northwind.Urunlers&#8221; koleksiyonundaki bir nesneyi i\u015faret etmektedir.&#8221;on&#8221; anahtar s\u00f6zc\u00fc\u011f\u00fc ile ili\u015fkili s\u00fctunlar\u0131 e\u015fitliyoruz.E\u015fitleme i\u015flemini &#8220;equals&#8221; komutuyla yap\u0131yoruz.<br \/>\n&#8211;Spain&#8217;de ya\u015fayan m\u00fc\u015fteriler ve bu m\u00fc\u015fterilere yap\u0131lan sat\u0131\u015f say\u0131s\u0131? Hi\u00e7 sat\u0131\u015f yap\u0131lmayan m\u00fc\u015fteriler listelenmesin.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            NorthwindDataContext Northwind = new NorthwindDataContext();\r\n            var Sonuc = from satis in Northwind.Satislars\r\n                        where satis.Musteriler.Ulke ==&quot;Spain&quot;\r\n                        join musteri in Northwind.Musterilers on satis.MusteriID equals musteri.MusteriID\r\n                        group satis by satis.Musteriler.MusteriAdi into Grup\r\n                        where Grup.Count() &gt; 0\r\n                        select new\r\n                        {\r\n                            Satis = Grup.Count(),\r\n                            MusteriAdi = Grup.Key\r\n                        };\r\n            foreach (var item in Sonuc)\r\n            {\r\n                listBox1.Items.Add(item.MusteriAdi + &quot; &quot; + item.Satis);\r\n            }\r\n<\/pre>\n<p>LINQ&#8217;da join yaparken, nesneler \u00fczerinden de birle\u015ftirme yapabiliriz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            NorthwindDataContext Northwind = new NorthwindDataContext();\r\n            var Sonuc = from musteri in Northwind.Musterilers\r\n                        where musteri.Ulke == &quot;Spain&quot;\r\n                        join satis in Northwind.Satislars on musteri equals satis.Musteriler\r\n                        group satis by satis.Musteriler.MusteriAdi into Grup\r\n                        select new {\r\n                            Satis = Grup.Count(),\r\n                            MusteriAdi = Grup.Key\r\n                        };\r\n            foreach (var item in Sonuc)\r\n            {\r\n                listBox1.Items.Add(item.Satis + &quot; &quot; + item.MusteriAdi);\r\n            }\r\n<\/pre>\n<p>\u0130yi \u00e7al\u0131\u015fmalar<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Linq To Sql&#8217;de Join i\u015flemleri nas\u0131l yap\u0131l\u0131r onu inceleyelim.<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,12,226],"tags":[233,229],"class_list":["post-663","post","type-post","status-publish","format-standard","hentry","category-asp-net","category-c-sharp-c","category-linq","tag-join","tag-linq-to-sql"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=663"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/663\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}