└── README.md /README.md: -------------------------------------------------------------------------------- 1 | A mapping of the feature set of the LINQ API to D's Range API. 2 | 3 | Filtering 4 | --------- 5 | 6 | LINQ | D 7 | -------|----- 8 | [`Where`](https://msdn.microsoft.com/en-us/library/bb534803.aspx) | [`filter`](http://dlang.org/phobos/std_algorithm_iteration.html#.filter) 9 | [`OfTyp`](https://msdn.microsoft.com/en-us/library/bb360913.aspx) | [`castSwitch`](http://dlang.org/phobos/std_algorithm_comparison.html#.castSwitch) 10 | 11 | Projections 12 | ----------- 13 | 14 | LINQ | D 15 | -------|----- 16 | [`Select`](https://msdn.microsoft.com/en-us/library/bb384087.aspx) | [`map`](http://dlang.org/phobos/std_algorithm_iteration.html#.map) 17 | [`SelectMany`](https://msdn.microsoft.com/en-us/library/bb534336.aspx) |= 18 | Anonoymous Types | [Tuples](https://dlang.org/phobos/std_typecons.html#.tuple) 19 | Indexed | [`enumerate`](http://dlang.org/phobos/std_range.html#enumerate) 20 | 21 | ``` 22 | from c in customers 23 | from o in c.Orders 24 | where c.Region == "WA" 25 | ``` 26 | 27 | Partitioning 28 | ------------ 29 | 30 | LINQ | D 31 | -------|----- 32 | [`Take`](https://msdn.microsoft.com/en-us/library/bb503062.aspx) | [`take`](http://dlang.org/phobos/std_range.html#take) 33 | [`Skip`](https://msdn.microsoft.com/en-us/library/bb358985.aspx) | [`drop`](http://dlang.org/phobos/std_range.html#.drop) 34 | [`TakeWhile`](https://msdn.microsoft.com/en-us/library/system.linq.enumerable.takewhile.aspx) | [`until`](https://dlang.org/phobos/std_algorithm_searching.html#.until) 35 | [`SkipWhile`](https://msdn.microsoft.com/en-us/library/system.linq.enumerable.skipwhile.aspx) | [`find`](https://dlang.org/phobos/std_algorithm_searching.html#.find) 36 | 37 | Ordering 38 | -------- 39 | 40 | LINQ | D 41 | -------|----- 42 | [`OrderBy`](https://msdn.microsoft.com/en-us/library/bb534966.aspx) | [`sort`](http://dlang.org/phobos/std_algorithm_sorting.html#.sort) 43 | `OrderBy` + Comparer | `sort` + `opCmp` 44 | [`OrderByDescending`](https://msdn.microsoft.com/en-us/library/bb534855.aspx) | [`sort`](http://dlang.org/phobos/std_algorithm_sorting.html#.sort) 45 | `OrderByDescending` + Comparer | `sort` + `opCmp` 46 | [`ThenBy`](https://msdn.microsoft.com/en-us/library/bb534743.aspx) | [`multiSort`](http://dlang.org/phobos/std_algorithm_sorting.html#.multiSort) 47 | `ThenBy` + Comparer | `multiSort` + `opCmp` 48 | [`ThenByDescending`](https://msdn.microsoft.com/en-us/library/bb534736.aspx) | [`multiSort`](http://dlang.org/phobos/std_algorithm_sorting.html#.multiSort) 49 | `ThenByDescending` + Comparer | `multiSort` + `opCmp` 50 | [`Reverse`](https://msdn.microsoft.com/en-us/library/bb358497.aspx) | [`retro`](http://dlang.org/phobos/std_range.html#.retro) 51 | 52 | Grouping 53 | -------- 54 | 55 | LINQ | D 56 | -------|----- 57 | [`GroupBy`](https://msdn.microsoft.com/en-us/library/system.linq.enumerable.groupby.aspx) | [`chunkBy`](https://dlang.org/phobos/std_algorithm_iteration.html#.chunkBy), [`group`](https://dlang.org/phobos/std_algorithm_iteration.html#.group) 58 | [`GroupJoin`][group-join] | 59 | 60 | Grouping: https://msdn.microsoft.com/en-us/library/mt693097.aspx 61 | 62 | [group-join]: https://msdn.microsoft.com/en-us/library/system.linq.enumerable.groupjoin(v=vs.110).aspx 63 | 64 | Set operators 65 | ------------- 66 | 67 | LINQ | D 68 | -------|----- 69 | [`Distinct`](https://msdn.microsoft.com/en-us/library/bb348436.aspx) | [`uniq`](https://dlang.org/phobos/std_algorithm_iteration.html#.uniq) 70 | [`Union`](https://msdn.microsoft.com/en-us/library/bb341731.aspx) | [`merge`](https://dlang.org/phobos/std_algorithm_sorting.html#.merge) 71 | [`Intersect`](https://msdn.microsoft.com/en-us/library/bb460136.aspx) | [`setIntersection`](http://dlang.org/phobos/std_algorithm_setops.html#.setIntersection) 72 | [`Except`](https://msdn.microsoft.com/en-us/library/bb300779.aspx) | [`setDifference`](https://dlang.org/phobos/std_algorithm_setops.html#setDifference) 73 | 74 | D expects sortedness of all inputs. 75 | 76 | Conversion 77 | ---------- 78 | 79 | LINQ | D 80 | -------|----- 81 | [`ToArray`](https://msdn.microsoft.com/en-us/library/bb298736.aspx) | [`array`](http://dlang.org/phobos/std_array.html#array) 82 | [`ToList`](https://msdn.microsoft.com/en-us/library/bb549277.aspx) | [`array`](http://dlang.org/phobos/std_array.html#array) 83 | [`ToDictionary`](https://msdn.microsoft.com/en-us/library/bb549277.aspx) | [`assocArray`](http://dlang.org/phobos/std_array.html#.assocArray) 84 | [`ToLookup`](https://msdn.microsoft.com/en-us/library/bb549073.aspx) | `chunkby.assocArray` 85 | [`Cast`](https://msdn.microsoft.com/en-us/library/bb341406.aspx) | no need (universal API) 86 | [`AsQueryable`](https://msdn.microsoft.com/en-us/library/bb353734.aspx) | [`isInputRange`](http://dlang.org/phobos/std_range_primitives.html#isInputRange) 87 | [`AsEnumerable`](https://msdn.microsoft.com/en-us/library/bb335435.aspx) | [`isRandomAccessRange`](http://dlang.org/phobos/std_range_primitives.html#isRandomAccessRange) 88 | OfType | `typeof` 89 | 90 | Element operators 91 | ----------------- 92 | 93 | LINQ | D 94 | -------|----- 95 | [`First`](https://msdn.microsoft.com/en-us/library/bb291976.aspx) | [`front`](https://dlang.org/phobos/std_range_primitives.html#.front) 96 | [`FirstOrDefault`](https://msdn.microsoft.com/en-us/library/bb340482.aspx) | `r.empty ? "default" : r.front` 97 | [`ElementAt`](https://msdn.microsoft.com/en-us/library/bb299233.aspx) | [`[]`] 98 | [`ElementAtOrDefault`](https://msdn.microsoft.com/en-us/library/bb494386.aspx) | `i < r.length ? "default" : r[i]` 99 | [`Last`](https://msdn.microsoft.com/en-us/library/bb358775.aspx) | [`back`](https://dlang.org/phobos/std_range_primitives.html#.back) 100 | [`LastOrDefault`](https://msdn.microsoft.com/en-us/library/bb301849.aspx) | `r.empty ? "default" : r.front` 101 | [`Single`](https://msdn.microsoft.com/en-us/library/bb155325.aspx) | `r.length == 1 ? r.front : throw new Exception("Range is supposed to contain a single value only")` 102 | [`SingleOrDefault`](https://msdn.microsoft.com/en-us/library/bb342451.aspx) | `r.length <= 1 ? (r.empty ? "default" : r.front ) : throw new Exception("Range is supposed to contain a single value only")` 103 | 104 | 105 | Generation operators 106 | ------------------- 107 | 108 | LINQ | D 109 | -------|----- 110 | [`Range`](https://msdn.microsoft.com/en-us/library/system.linq.enumerable.range.aspx) | [`iota`](http://dlang.org/phobos/std_range.html#iota) 111 | [`Repeat`](https://msdn.microsoft.com/en-us/library/bb348899.aspx) | [`repeat`](http://dlang.org/phobos/std_range.html#repeat) 112 | [`Empty`](https://msdn.microsoft.com/en-us/library/bb341042.aspx) | `empty` 113 | [`DefaultIfEmpty`](https://msdn.microsoft.com/en-us/library/bb360179.aspx) | `r.empty ? "default" : r.front` 114 | 115 | Quantifiers 116 | ------------ 117 | 118 | LINQ | D 119 | -------|----- 120 | [`Any`](https://msdn.microsoft.com/en-us/library/bb548541.aspx) | [`any`](http://dlang.org/phobos/std_algorithm_searching.html#.any) 121 | [`All`](https://msdn.microsoft.com/en-us/library/bb534972.aspx) | [`all`](http://dlang.org/phobos/std_algorithm_searching.html#.all) 122 | [`Contains`](https://msdn.microsoft.com/en-us/library/bb352880.aspx) | [`find`](https://dlang.org/phobos/std_algorithm_searching.html#.find), [`canFind`](http://dlang.org/phobos/std_algorithm_searching.html#.canFind) 123 | 124 | Aggregate 125 | --------- 126 | 127 | LINQ | D 128 | -------|----- 129 | [`Count`](https://msdn.microsoft.com/en-us/library/bb338038.aspx) | `length` if RandomAccess, otherwise [`walkLength`](https://dlang.org/phobos/std_range_primitives.html#.walkLength) 130 | [`Sum`](https://msdn.microsoft.com/en-us/library/bb298138.aspx) | [`sum`](http://dlang.org/phobos/std_algorithm_iteration.html#.sum) 131 | [`Min`](https://msdn.microsoft.com/en-us/library/bb298087.aspx) | [`minElement`](https://dlang.org/phobos/std_algorithm_searching.html#.minElement) 132 | [`Max`](https://msdn.microsoft.com/en-us/library/bb335614.aspx) | [`maxElement`](https://dlang.org/phobos/std_algorithm_searching.html#.maxElement) 133 | [`Average`](https://msdn.microsoft.com/en-us/library/bb354760.aspx) | 134 | [`Aggregate`](https://msdn.microsoft.com/en-us/library/bb548651.aspx) | [`reduce`](http://dlang.org/phobos/std_algorithm_iteration.html#.reduce) 135 | [`LongCount`](https://msdn.microsoft.com/en-us/library/bb353539.aspx) | `length` / `walkLength` use `size_t` 136 | 137 | Equality 138 | -------- 139 | 140 | LINQ | D 141 | -------|----- 142 | [`SequenceEqual`](https://msdn.microsoft.com/en-us/library/bb348567.aspx) | [`equal`](http://dlang.org/phobos/std_algorithm_comparison.html#.equal) 143 | 144 | Concatenation 145 | ------------- 146 | 147 | LINQ | D 148 | -------|----- 149 | [`Concat`](https://msdn.microsoft.com/en-us/library/bb302894.aspx) | [`chain`](http://dlang.org/phobos/std_range.html#.chain) 150 | 151 | Query execution 152 | --------------- 153 | 154 | LINQ | D 155 | -------|----- 156 | Deferred Execution | Ranges in D are lazy 157 | Immediate Execution | e.g. [`each`](http://dlang.org/phobos/std_algorithm_iteration.html#.each) 158 | Query Reuse | [`save`](https://dlang.org/phobos/std_range_primitives.html#.save) 159 | Custom generator | [`generate`](http://dlang.org/phobos/std_range.html#.generate) 160 | 161 | Joins 162 | ----- 163 | 164 | - Cross Join 165 | - Group Join 166 | - Cross Join with Group Join 167 | - Left Outer Join 168 | 169 | https://msdn.microsoft.com/en-us/library/mt693045.aspx 170 | --------------------------------------------------------------------------------