Recently I upgraded one of my projects to use .NET 6
. Earlier I was using
I am able to replicate the same issue in the below fiddle
CodePudding user response:
You can't alias an extension method, but you can call the extension like a normal method, using the full namespace. After all, extension methods are really just syntactic sugar. For example (using the same data you provided in your fiddle):
var inputs = new []
{
new {Name = "Bruce wayne", State = "New York"},
new {Name = "Rajnikant", State = "Tamil Nadu"},
new {Name = "Robert Downey jr", State = "Pennsylvania"},
new {Name = "Dwane Johnson", State = "Pennsylvania"},
new {Name = "Hritik", State = "Maharashtra"}
};
var net6DistinctBy = System.Linq.Enumerable.DistinctBy(inputs, x => x.State);
var moreLinqDistinctBy = MoreLinq.MoreEnumerable.DistinctBy(inputs, x => x.State);