[{"data":1,"prerenderedAt":423},["ShallowReactive",2],{"blog:2007:linq-in-60-seconds":3,"blogMore-Development":409,"comments-linq-in-60-seconds":422},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"category":11,"tags":12,"excerpt":16,"body":36,"_type":400,"_id":401,"_source":402,"_file":403,"_stem":404,"_extension":405,"url":406,"wordCount":407,"minutes":149,"commentCount":408},"/blog/2007/linq-in-60-seconds","2007",false,"en","LINQ in 60 seconds","Microsoft’s Language INtegrated Query (LINQ) aims to provide a way of selecting objects with a common syntax independent of the data source.","2007-09-03T19:41:58+00:00","Development",[13,14,15],".NET","LINQ","C#",{"type":17,"children":18},"root",[19,31],{"type":20,"tag":21,"props":22,"children":23},"element","p",{},[24,27,29],{"type":25,"value":26},"text","Microsoft’s ",{"type":25,"value":28},"Language INtegrated Query (LINQ)",{"type":25,"value":30}," aims to provide a way of selecting objects with a common syntax independent of the data source.",{"type":20,"tag":21,"props":32,"children":33},{},[34],{"type":25,"value":35},"By integrating query into the language instead strings parsed by an external provider at runtime we gain IntelliSense prompting for fields, members and table names and full compile-time syntax checking and a unified syntax.",{"type":17,"children":37,"toc":390},[38,51,55,69,76,90,221,227,240,260,266,278,283,288,294,308,315,328,334,348,354,375,384],{"type":20,"tag":21,"props":39,"children":40},{},[41,42,50],{"type":25,"value":26},{"type":20,"tag":43,"props":44,"children":48},"a",{"href":45,"rel":46},"https://msdn2.microsoft.com/en-us/netframework/aa904594.aspx",[47],"nofollow",[49],{"type":25,"value":28},{"type":25,"value":30},{"type":20,"tag":21,"props":52,"children":53},{},[54],{"type":25,"value":35},{"type":20,"tag":21,"props":56,"children":57},{},[58,60,67],{"type":25,"value":59},"They will be included in the .NET Framework 3.5 and delivered as part of the Visual Studio 2008 ‘Orcas’ release which is ",{"type":20,"tag":43,"props":61,"children":64},{"href":62,"rel":63},"https://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx",[47],[65],{"type":25,"value":66},"currently available in beta",{"type":25,"value":68}," and comprises of:",{"type":20,"tag":70,"props":71,"children":73},"h2",{"id":72},"linq-syntax",[74],{"type":25,"value":75},"LINQ syntax",{"type":20,"tag":21,"props":77,"children":78},{},[79,81,88],{"type":25,"value":80},"The ",{"type":20,"tag":43,"props":82,"children":85},{"href":83,"rel":84},"https://msdn2.microsoft.com/en-gb/library/bb308959.aspx#linqoverview_topic5",[47],[86],{"type":25,"value":87},"language extensions themselves",{"type":25,"value":89},". An example in C# might look like:",{"type":20,"tag":91,"props":92,"children":97},"pre",{"className":93,"code":94,"language":95,"meta":96,"style":96},"language-csharp shiki shiki-themes everforest-light dracula","GridView1.DataSource = from country in countries\n                       where country.Continent == 'Europe'\n                       orderby population descending\n                       select country;\n","csharp","",[98],{"type":20,"tag":99,"props":100,"children":101},"code",{"__ignoreMap":96},[102,147,188,207],{"type":20,"tag":103,"props":104,"children":107},"span",{"class":105,"line":106},"line",1,[108,114,120,126,132,137,142],{"type":20,"tag":103,"props":109,"children":111},{"style":110},"--shiki-default:#5C6A72;--shiki-dark:#F8F8F2",[112],{"type":25,"value":113},"GridView1.",{"type":20,"tag":103,"props":115,"children":117},{"style":116},"--shiki-default:#35A77C;--shiki-dark:#F8F8F2",[118],{"type":25,"value":119},"DataSource",{"type":20,"tag":103,"props":121,"children":123},{"style":122},"--shiki-default:#F57D26;--shiki-dark:#FF79C6",[124],{"type":25,"value":125}," =",{"type":20,"tag":103,"props":127,"children":129},{"style":128},"--shiki-default:#F85552;--shiki-dark:#FF79C6",[130],{"type":25,"value":131}," from",{"type":20,"tag":103,"props":133,"children":134},{"style":110},[135],{"type":25,"value":136}," country ",{"type":20,"tag":103,"props":138,"children":139},{"style":128},[140],{"type":25,"value":141},"in",{"type":20,"tag":103,"props":143,"children":144},{"style":110},[145],{"type":25,"value":146}," countries\n",{"type":20,"tag":103,"props":148,"children":150},{"class":105,"line":149},2,[151,156,161,166,171,177,183],{"type":20,"tag":103,"props":152,"children":153},{"style":128},[154],{"type":25,"value":155},"                       where",{"type":20,"tag":103,"props":157,"children":158},{"style":110},[159],{"type":25,"value":160}," country.",{"type":20,"tag":103,"props":162,"children":163},{"style":116},[164],{"type":25,"value":165},"Continent",{"type":20,"tag":103,"props":167,"children":168},{"style":122},[169],{"type":25,"value":170}," ==",{"type":20,"tag":103,"props":172,"children":174},{"style":173},"--shiki-default:#5C6A72;--shiki-dark:#F1FA8C",[175],{"type":25,"value":176}," '",{"type":20,"tag":103,"props":178,"children":180},{"style":179},"--shiki-default:#8DA101;--shiki-dark:#F1FA8C",[181],{"type":25,"value":182},"Europe",{"type":20,"tag":103,"props":184,"children":185},{"style":173},[186],{"type":25,"value":187},"'\n",{"type":20,"tag":103,"props":189,"children":191},{"class":105,"line":190},3,[192,197,202],{"type":20,"tag":103,"props":193,"children":194},{"style":128},[195],{"type":25,"value":196},"                       orderby",{"type":20,"tag":103,"props":198,"children":199},{"style":110},[200],{"type":25,"value":201}," population ",{"type":20,"tag":103,"props":203,"children":204},{"style":128},[205],{"type":25,"value":206},"descending\n",{"type":20,"tag":103,"props":208,"children":210},{"class":105,"line":209},4,[211,216],{"type":20,"tag":103,"props":212,"children":213},{"style":128},[214],{"type":25,"value":215},"                       select",{"type":20,"tag":103,"props":217,"children":218},{"style":110},[219],{"type":25,"value":220}," country;\n",{"type":20,"tag":70,"props":222,"children":224},{"id":223},"linq-to-objects",[225],{"type":25,"value":226},"LINQ to Objects",{"type":20,"tag":21,"props":228,"children":229},{},[230,232,238],{"type":25,"value":231},"A core part of the .NET Framework 3.5 and allows you to query against any ",{"type":20,"tag":99,"props":233,"children":235},{"className":234},[],[236],{"type":25,"value":237},"IEnumerable\u003CT>",{"type":25,"value":239}," collection and test or sort against any of T’s properties.",{"type":20,"tag":21,"props":241,"children":242},{},[243,245,251,253,258],{"type":25,"value":244},"In the above example imagine Country is a business class and Countries is a ",{"type":20,"tag":99,"props":246,"children":248},{"className":247},[],[249],{"type":25,"value":250},"List\u003CCountry>",{"type":25,"value":252},". ",{"type":20,"tag":99,"props":254,"children":256},{"className":255},[],[257],{"type":25,"value":165},{"type":25,"value":259}," is a string property and population a numeric one.",{"type":20,"tag":70,"props":261,"children":263},{"id":262},"linq-to-sql-formerly-known-as-dlinq",[264],{"type":25,"value":265},"LINQ to SQL (formerly known as DLinq)",{"type":20,"tag":21,"props":267,"children":268},{},[269,276],{"type":20,"tag":43,"props":270,"children":273},{"href":271,"rel":272},"https://msdn2.microsoft.com/en-gb/library/bb425822.aspx",[47],[274],{"type":25,"value":275},"LINQ to SQL",{"type":25,"value":277}," works by mapping classes and properties to tables and fields as any normal Object-Relational Mapping (ORM) tool would.",{"type":20,"tag":21,"props":279,"children":280},{},[281],{"type":25,"value":282},"It achieves this by marking the classes and properties with attributes to indicate how they map to the underlying database. A visual modeling tool is provided that can generate and manipulate such classes for you from an existing SQL database.",{"type":20,"tag":21,"props":284,"children":285},{},[286],{"type":25,"value":287},"The ORM functionality includes tracking of changed objects and change persistence. It also ensures that you will not obtain multiple objects for the same underlying row in the database (Fowler’s Identity Map).",{"type":20,"tag":70,"props":289,"children":291},{"id":290},"other-components",[292],{"type":25,"value":293},"Other components",{"type":20,"tag":21,"props":295,"children":296},{},[297,299,306],{"type":25,"value":298},"There are many other components in the ",{"type":20,"tag":43,"props":300,"children":303},{"href":301,"rel":302},"https://msdn2.microsoft.com/en-gb/netframework/aa904594.aspx",[47],[304],{"type":25,"value":305},"LINQ family",{"type":25,"value":307}," including:",{"type":20,"tag":309,"props":310,"children":312},"h3",{"id":311},"linq-to-xml-formerly-known-as-xlinq",[313],{"type":25,"value":314},"LINQ to XML (formerly known as XLinq)",{"type":20,"tag":21,"props":316,"children":317},{},[318,320,326],{"type":25,"value":319},"Similar to LINQ to SQL but along the idea of ",{"type":20,"tag":43,"props":321,"children":323},{"href":301,"rel":322},[47],[324],{"type":25,"value":325},"querying XML documents",{"type":25,"value":327}," using LINQ syntax rather than the XPath/XQuery syntax.",{"type":20,"tag":309,"props":329,"children":331},{"id":330},"linq-to-entities-adonet-entities",[332],{"type":25,"value":333},"LINQ to Entities (ADO.NET Entities)",{"type":20,"tag":21,"props":335,"children":336},{},[337,339,346],{"type":25,"value":338},"A ",{"type":20,"tag":43,"props":340,"children":343},{"href":341,"rel":342},"https://msdn2.microsoft.com/en-us/library/aa697427(vs.80).aspx",[47],[344],{"type":25,"value":345},"more advanced ORM solution",{"type":25,"value":347}," that allows more extensive mapping and manipulation between how the object appears and the underlying data source.",{"type":20,"tag":70,"props":349,"children":351},{"id":350},"third-party-support",[352],{"type":25,"value":353},"Third-party support",{"type":20,"tag":21,"props":355,"children":356},{},[357,364,366,373],{"type":20,"tag":43,"props":358,"children":361},{"href":359,"rel":360},"https://www.mono-project.com/Mono_Project_Roadmap",[47],[362],{"type":25,"value":363},"Mono is actively implementing LINQ",{"type":25,"value":365}," as are the people behind the ",{"type":20,"tag":43,"props":367,"children":370},{"href":368,"rel":369},"https://www.ayende.com/Blog/archive/2007/03/16/Linq-for-NHibernate.aspx",[47],[371],{"type":25,"value":372},"NHibernate ORM",{"type":25,"value":374},".",{"type":20,"tag":21,"props":376,"children":377},{},[378],{"type":20,"tag":379,"props":380,"children":381},"em",{},[382],{"type":25,"value":383},"[)amien",{"type":20,"tag":385,"props":386,"children":387},"style",{},[388],{"type":25,"value":389},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":96,"searchDepth":149,"depth":149,"links":391},[392,393,394,395,399],{"id":72,"depth":149,"text":75},{"id":223,"depth":149,"text":226},{"id":262,"depth":149,"text":265},{"id":290,"depth":149,"text":293,"children":396},[397,398],{"id":311,"depth":190,"text":314},{"id":330,"depth":190,"text":333},{"id":350,"depth":149,"text":353},"markdown","content:blog:2007:linq-in-60-seconds.md","content","blog/2007/linq-in-60-seconds.md","blog/2007/linq-in-60-seconds","md","/blog/2007/linq-in-60-seconds/",392,0,[410,414,418],{"title":411,"date":412,"url":413},"HTML5 Video Cheatsheet: Optimizing videos for the web","2025-12-05T00:00:00Z","/blog/2025/html5-video-cheatsheet/",{"title":415,"date":416,"url":417},"Transactions in the MongoDB EF Core Provider","2025-10-25","/blog/2025/mongodb-explicit-transactions/",{"title":419,"date":420,"url":421},"Queryable Encryption with the MongoDB EF Core Provider","2025-09-22","/blog/2025/mongodb-queryable-encryption/",[],1779264591730]