LINQ Tips and Tricks

Search Results: https://www.ecosia.org/search?q=linq+tricks&addon=opensearch

LINQ Tips and Tricks:https://markheath.net/post/linq-tips-and-tricks

Here is a quick overview:

  1. Use LINQPad
  2. Think in Patterns
  3. Use Pipelines
  4. Be Lazy
  5. Extend LINQ
  6. Optimize Performance
  7. Understand the Underlying SQL

Learn to Love LINQ:
https://gist.github.com/jehugaleahsa/9d92be18e642bc65d7a167c621d91e90

  • Query vs Method syntax
  • Use multiples wheres to break up long conditionals
  • Use where anywhere
  • Uniqueness on multiple keys
  • Using into and let
  • DefaultIfEmpty and left-joins
  • Joins and alternatives
  • Include always at the end
  • Avoiding null tests
  • Any() && !Skip(1).Any()
  • UniqueOrDefault
  • Enumerable.Repeat(x, 1) and Enumerable.Empty().DefaultIfEmpty(x)
  • Building up an IEnumerable

50 LINQ Examples, Tips and How To’s
https://www.dotnetcurry.com/linq/727/linq-examples-tips-tricks

  1. List.ConvertAll>>() with Lambda Expression
  2. Calculate the Size of a Folder/Directory using .NET 4.0
  3. LINQ: Generate Odd Numbers using Parallel Execution
  4. LINQ: Compare two Sequences
  5. LINQ: Calculate Average File Size in C#
  6. LINQ: Generate a Cartesian Product
  7. LINQ: List Classes implementing the IEnumerable Interface
  8. Find Uppercase words in a String using C#
  9. LINQ: Query Comma Separated Value (CSV) files
  10. Generate Odd Numbers within a Range using LINQ
  11. Generate Sequence of Float Numbers within a Range using LINQ
  12. Query a Sequence using LINQ
  13. Divide Sequence into Groups and Query using LINQ
  14. LINQ – Left Join Example in C#
  15. Inner Join Example in LINQ and C#
  16. Using from-let-where Clause in LINQ
  17. List all .NET Attributes in the Loaded Assemblies
  18. Rewrite Nested ForEach Loop in LINQ
  19. Count File Extensions and Group it using LINQ
  20. Swap Words inside a String using LINQ
  21. Filter a Type in .NET inside the For-Each Loop
  22. Split a String Collection into Groups using LINQ
  23. Highest Value in each Group using LINQ
  24. Loop through Master-Detail Records using LINQ
  25. Concatenate Unique Elements of two List<String> and Sort using LINQ
  26. List all Files in .NET 4.0 Based on the Creation Date
  27. Skip and Select Elements in a String Array using LINQ
  28. Enumerate Hidden Directories in .NET 4.0
  29. Ordering Elements of a List by Length and Content
  30. Distinct OrderBy in LINQ
  31. Using LINQ to select Only Strings from an ArrayList
  32. Combine Multiple Sequences in LINQ using the Zip Operator
  33. Sort a String Array containing Numbers using LINQ
  34. Join Two String Arrays with Distinct values using LINQ
  35. Using TrueForAll with Generic Lists
  36. Determine all Types that Implement an Interface
  37. Using LINQ to Find Top 5 Processes that are Consuming Memory
  38. Find Distinct Text Using LINQ
  39. Using LINQ to Search and Delete Old Files
  40. Using LINQ to Find the Sum of a MultiDimensional Array
  41. Get Unique Selected Items From Multiple ASP.NET ListBox and Merge them using LINQ
  42. How to Sort Data using LINQ
  43. Retrieve Selected Items of an ASP.NET ListBox using LINQ
  44. Replicating the ‘IN’ operator in LINQ
  45. Implementing Paging in a Generic List using LINQ
  46. LINQ to XML
  47. LINQ to XML Sorting
  48. Serialize XDocument in LINQ To XML
  49. Select Last N elements using LINQ to XML
  50. Create a XML Tree from a String

Leave a Reply

Your email address will not be published. Required fields are marked *