{"id":84,"date":"2011-07-19T23:16:00","date_gmt":"2011-07-19T23:16:00","guid":{"rendered":"http:\/\/madprogrammer76.wordpress.com\/2011\/07\/19\/why-use-linq"},"modified":"2011-07-19T23:16:00","modified_gmt":"2011-07-19T23:16:00","slug":"why-use-linq","status":"publish","type":"post","link":"https:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/","title":{"rendered":"Why use LINQ"},"content":{"rendered":"<p>I was asked &#8220;Why I never used LINQ?&#8221; \u00a0 I guess the real answer was, I\u00a0never thought about it. \u00a0I really had no good reason for not using LINQ other it was new and unfamiliar. \u00a0When I finally used LINQ; I found I was\u00a0getting rid of old habits and making code simpler and cleaner. <br \/><b><\/b><\/p>\n<blockquote><p><b>Example of code written in C#:<\/b><\/p>\n<pre>foreach (Charges charge in (ary))<br \/>{<br \/>     if (charge.ChargeDescription.ToLower().Contains(\"total\"))<br \/>     {<br \/>         ary.Remove(charge);<br \/>     }<br \/>}<br \/><\/pre>\n<p><b>Code converted to LINQ:<\/b><\/p>\n<pre>var rslt = from Charges charge in ary where charge.ChargeDescription.ToLower().Contains(\"total\") select charge;<br \/><br \/>while(rslt.Count() &gt; 0)<br \/>{<br \/>        Charges chargese = rslt.ElementAt(0);<br \/>        ary.RemoveAt(ary.IndexOf(Chargese));<br \/>}<\/pre>\n<\/blockquote>\n<p>To this day I still use C# with a little LINQ to\u00a0simplify\u00a0my code. \u00a0 I use LINQ for validations, quick look up and data manipulations. \u00a0It is definitely a change from what I used to do, but worth learning. \u00a0What I like about the above code is I had eliminated the nested if without complicating the code.<\/p>\n<div class=\"blogger-post-footer\"><img width='1' height='1' src='' alt='' \/><\/div>\n","protected":false},"excerpt":{"rendered":"<p>I was asked &#8220;Why I never used LINQ?&#8221; \u00a0 I guess the real answer was, I\u00a0never thought about it. \u00a0I really had no good reason for not using LINQ other it was new and unfamiliar. \u00a0When I finally used LINQ; I found I was\u00a0getting rid of old habits and making code simpler and cleaner. Example &hellip; <a href=\"https:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Why use LINQ<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,25,48],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\r\n<title>Why use LINQ - LDNDeveloper<\/title>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"Why use LINQ - LDNDeveloper\" \/>\r\n<meta property=\"og:description\" content=\"I was asked &#8220;Why I never used LINQ?&#8221; \u00a0 I guess the real answer was, I\u00a0never thought about it. \u00a0I really had no good reason for not using LINQ other it was new and unfamiliar. \u00a0When I finally used LINQ; I found I was\u00a0getting rid of old habits and making code simpler and cleaner. Example &hellip; Continue reading Why use LINQ\" \/>\r\n<meta property=\"og:url\" content=\"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/\" \/>\r\n<meta property=\"og:site_name\" content=\"LDNDeveloper\" \/>\r\n<meta property=\"article:published_time\" content=\"2011-07-19T23:16:00+00:00\" \/>\r\n<meta name=\"author\" content=\"andrewpallant\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:creator\" content=\"@ldnDeveloper\" \/>\r\n<meta name=\"twitter:site\" content=\"@LdnDeveloper\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"andrewpallant\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/\"},\"author\":{\"name\":\"andrewpallant\",\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/0e7b5e71751000e8f66b17b69ef4ab97\"},\"headline\":\"Why use LINQ\",\"datePublished\":\"2011-07-19T23:16:00+00:00\",\"dateModified\":\"2011-07-19T23:16:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/\"},\"wordCount\":126,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84\"},\"articleSection\":[\"C#\",\"DotNet\",\"LINQ\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/\",\"url\":\"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/\",\"name\":\"Why use LINQ - LDNDeveloper\",\"isPartOf\":{\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#website\"},\"datePublished\":\"2011-07-19T23:16:00+00:00\",\"dateModified\":\"2011-07-19T23:16:00+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/andrewpallant.ca\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Why use LINQ\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#website\",\"url\":\"https:\/\/andrewpallant.ca\/wordpress\/\",\"name\":\"LDNDeveloper\",\"description\":\"Learning, Growing and Sharing.\",\"publisher\":{\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/andrewpallant.ca\/wordpress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84\",\"name\":\"ldnDeveloper\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg\",\"contentUrl\":\"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg\",\"width\":512,\"height\":512,\"caption\":\"ldnDeveloper\"},\"logo\":{\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/\"},\"description\":\"Andrew Pallant (@LdnDeveloper) has been a web, database and desktop developer for over 16 years. Andrew has worked on projects that ranged from factory automation to writing business applications. Most recently he has been heavily involved in various forms for ecommerce projects. Over the years Andrew has worn many hats: Project Manager, IT Manager, Lead Developer, Supervisor of Developers and many more - See more at: http:\/\/www.unlatched.com\/#sthash.8DiTkpKy.dpuf\",\"sameAs\":[\"http:\/\/www.andrewpallant.ca\",\"https:\/\/x.com\/LdnDeveloper\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/0e7b5e71751000e8f66b17b69ef4ab97\",\"name\":\"andrewpallant\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"caption\":\"andrewpallant\"},\"url\":\"https:\/\/andrewpallant.ca\/wordpress\/author\/andrewpallant\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Why use LINQ - LDNDeveloper","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/","og_locale":"en_US","og_type":"article","og_title":"Why use LINQ - LDNDeveloper","og_description":"I was asked &#8220;Why I never used LINQ?&#8221; \u00a0 I guess the real answer was, I\u00a0never thought about it. \u00a0I really had no good reason for not using LINQ other it was new and unfamiliar. \u00a0When I finally used LINQ; I found I was\u00a0getting rid of old habits and making code simpler and cleaner. Example &hellip; Continue reading Why use LINQ","og_url":"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/","og_site_name":"LDNDeveloper","article_published_time":"2011-07-19T23:16:00+00:00","author":"andrewpallant","twitter_card":"summary_large_image","twitter_creator":"@ldnDeveloper","twitter_site":"@LdnDeveloper","twitter_misc":{"Written by":"andrewpallant","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/#article","isPartOf":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/"},"author":{"name":"andrewpallant","@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/0e7b5e71751000e8f66b17b69ef4ab97"},"headline":"Why use LINQ","datePublished":"2011-07-19T23:16:00+00:00","dateModified":"2011-07-19T23:16:00+00:00","mainEntityOfPage":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/"},"wordCount":126,"commentCount":0,"publisher":{"@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84"},"articleSection":["C#","DotNet","LINQ"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/","url":"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/","name":"Why use LINQ - LDNDeveloper","isPartOf":{"@id":"https:\/\/andrewpallant.ca\/wordpress\/#website"},"datePublished":"2011-07-19T23:16:00+00:00","dateModified":"2011-07-19T23:16:00+00:00","breadcrumb":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/andrewpallant.ca\/wordpress\/why-use-linq\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/andrewpallant.ca\/wordpress\/"},{"@type":"ListItem","position":2,"name":"Why use LINQ"}]},{"@type":"WebSite","@id":"https:\/\/andrewpallant.ca\/wordpress\/#website","url":"https:\/\/andrewpallant.ca\/wordpress\/","name":"LDNDeveloper","description":"Learning, Growing and Sharing.","publisher":{"@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/andrewpallant.ca\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84","name":"ldnDeveloper","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg","contentUrl":"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg","width":512,"height":512,"caption":"ldnDeveloper"},"logo":{"@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/"},"description":"Andrew Pallant (@LdnDeveloper) has been a web, database and desktop developer for over 16 years. Andrew has worked on projects that ranged from factory automation to writing business applications. Most recently he has been heavily involved in various forms for ecommerce projects. Over the years Andrew has worn many hats: Project Manager, IT Manager, Lead Developer, Supervisor of Developers and many more - See more at: http:\/\/www.unlatched.com\/#sthash.8DiTkpKy.dpuf","sameAs":["http:\/\/www.andrewpallant.ca","https:\/\/x.com\/LdnDeveloper"]},{"@type":"Person","@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/0e7b5e71751000e8f66b17b69ef4ab97","name":"andrewpallant","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","caption":"andrewpallant"},"url":"https:\/\/andrewpallant.ca\/wordpress\/author\/andrewpallant\/"}]}},"_links":{"self":[{"href":"https:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/posts\/84"}],"collection":[{"href":"https:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/comments?post=84"}],"version-history":[{"count":0,"href":"https:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/posts\/84\/revisions"}],"wp:attachment":[{"href":"https:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/media?parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/categories?post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/tags?post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}