Questions tagged [morelinq]

MoreLINQ is a .Net library that provides a set of helper extension methods to simplify data collection processing.

MoreLINQ is a .Net library mainly providing extension methods for IEnumerable complementing the built-in LINQ to objects.

Relevant links:

47 questions
13
votes
5 answers

How to resolve ambiguous ZIP call between Enumerable and MoreLINQ?

I've ran into problem with extension method resolution. LINQ and MoreLINQ contain zip method, it was present in .NET since 4.0 version and was always in MoreLINQ library. But you can't use one of the implementation with nice-old extension method…
Ilya Ivanov
  • 23,148
  • 4
  • 64
  • 90
11
votes
2 answers

.net6 & MoreLinq : Call is ambiguous between System.Linq.Enumerable.DistinctBy and MoreLinq.MoreEnumerable.DistinctBy

Recently I upgraded one of my projects to use .NET 6. Earlier I was using MoreLinq library to use DistinctBy() to apply it on the specific property. Now as I upgraded TargetFramework to .NET 6, this change come up with inbuilt support to…
Prasad Telkikar
  • 15,207
  • 5
  • 21
  • 44
10
votes
3 answers

MoreLinq Acquire. What does it do?

I was inspecting the Jon Skeet's MoreLinq and I became curious about the acquire extension source code The implementation is as follows /// /// Ensures that a source sequence of ///…
Luis Filipe
  • 8,488
  • 7
  • 48
  • 76
5
votes
1 answer

MoreLinq maxBy vs LINQ max + where

I am using EF5 with the MoreLinq extenstion, while testing my program in production (very big database), I found out that the line: var x = db.TheBigTable.MaxBy(x => x.RecordTime); Takes very long time (RecordTime is a non-indexed datetime) Is that…
Ofiris
  • 6,047
  • 6
  • 35
  • 58
4
votes
4 answers

How to chunkify an IEnumerable, without losing/discarding items in case of failure?

I have a producer-consumer scenario where the producer is an enumerable sequence of items (IEnumerable). I want to process these items in chunks/batches of 10 items each. So I decided to use the new (.NET 6) Chunk LINQ operator, as suggested…
Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104
4
votes
1 answer

MoreLinq ExceptBy with only one matching property

I have 2 different items that I'm trying to perform the except by method using the more linq library. The only thing that is common between both items is a single string called Symbol. Item 1 is a list of tuples and Item 2 is a database table that I…
DarthVegan
  • 1,719
  • 7
  • 25
  • 42
4
votes
2 answers

Can anyone explain this enumerator syntax?

public static IEnumerable Pipe(this IEnumerable source, Action action) { return _(); IEnumerable _() { foreach (var element in source) { action(element); yield return element; …
Bohdan Other
  • 164
  • 7
4
votes
1 answer

Return 0 if no duplicates found from DistinctBy

I thought this would have been simple, but unfortunately I cannot find an answer to what I'm looking for. What I'd like to achieve, is return a list of distinctive results if they're duplicated, otherwise return 0 instead of singular items. The code…
Widunder
  • 295
  • 3
  • 19
4
votes
3 answers

How can I use 'continue' and `break` in an extension method?

I have defined the following extension method: public static void ForEach(this IEnumerable sequence, Action action) { foreach (T obj in sequence) { action(obj); } } I can then use it as: new [] {1, 2, 3} // an…
MaYaN
  • 6,683
  • 12
  • 57
  • 109
3
votes
4 answers

How can I check that a sequence of indices of type int are contiguous?

I have a Column class which has an Index property of type int. If I have a collection of Column objects, I am looking for a way to test if their indices are contiguous. By contiguous I mean that the indices are next to each other, so if ordered by…
Cleve
  • 1,273
  • 1
  • 13
  • 26
3
votes
4 answers

Select Distinct Count is really slow

I have a loop of about 7000 objects and within the loop I need to get a distinct count of a list of structs. Currently I am using - foreach (var product in productsToSearch) { Console.WriteLine("Time elapsed: {0} start", stopwatch.Elapsed); …
James Dev
  • 2,979
  • 1
  • 11
  • 16
3
votes
2 answers

Linq distinct based on two columns

I've a requirement where I need to fetch the unique records with same combination in 2 columns. My data would be Like CA(Column A) and CB(Column B) with some data CA CB 1 2 1 2 3 4 5 6 2 1 1 6 1 6 5 1 Let's say, I need to fetch records with value 1…
RealSteel
  • 1,871
  • 3
  • 37
  • 74
3
votes
2 answers

Getting the MoreLinq MaxBy function to return more than one element

I have a situation in which I have a list of objects with an int property and I need to retrieve the 3 objects with the highest value for that property. The MoreLinq MaxBy function is very convenient to find the single highest, but is there a way I…
Fenoec
  • 179
  • 2
  • 8
2
votes
2 answers

From a list, generate a dictionary of each entry's position in the list?

Given a list of distinct items, I want to get a dictionary lookup for each element's index in the list. I can write this in normal code like the following: //reference C# pseudocode interface IThing { int Id {get;} } ... List things =…
Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
2
votes
1 answer

.NET Framework 4.7.2 with MoreLINQ

I am trying to update a large solution to .NET Framework 4.7.2 with VS2019. One of the problems with this solution is that it is a large plugin type architecture, where (for many reasons) I am not able to recompile and release the plugins to…
debracey
  • 6,517
  • 1
  • 30
  • 56
1
2 3 4