SO CSharp
81 subscribers
1.43K photos
73 videos
80 links
Some stuff about about software development and related (devops, cs, ai, etc.). Stolen memes (mostly), some rare #random_PoK (random Piece of Knowledge), stream notifications. Also #weekendmeme
Download Telegram
SO CSharp
#sql #query #where
πŸ’―2πŸ‘1πŸ”₯1😁1πŸ—Ώ1
Just finished reading the huge Performance Improvements in .NET 10 article.

There’s a ton of interesting stuff in there, and I might eventually write a β€œsmall” summary of it. But for now, here’s a new #random_PoK (random Piece of Knowledge) :

Finally .NET has dedicated LeftJoin and RightJoin LINQ methods!

No more monstrous GroupJoin + SelectMany + DefaultIfEmpty constructs β€” and for LINQ to Objects, it’s even faster:

[MemoryDiagnoser(displayGenColumns: false)]
[HideColumns("Job", "Error", "StdDev", "Median", "RatioSD")]
public partial class Tests
{
private IEnumerable<int> Outer { get; } = Enumerable.Sequence(0, 1000, 2);
private IEnumerable<int> Inner { get; } = Enumerable.Sequence(0, 1000, 3);

[Benchmark(Baseline = true)]
public int LeftJoin_Manual() =>
ManualLeftJoin(Outer, Inner, o => o, i => i, (o, i) => o + i).Count();

[Benchmark]
public int LeftJoin_Linq() =>
Outer.LeftJoin(Inner, o => o, i => i, (o, i) => o + i).Count();

private static IEnumerable<TResult> ManualLeftJoin<TOuter, TInner, TKey, TResult>(
IEnumerable<TOuter> outer, IEnumerable<TInner> inner,
Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector,
Func<TOuter, TInner?, TResult> resultSelector) =>
outer
.GroupJoin(inner, outerKeySelector, innerKeySelector, (o, inners) => (o, inners))
.SelectMany(x => x.inners.DefaultIfEmpty(), (x, i) => resultSelector(x.o, i));
}

|Method         |Mean    |Ratio|Allocated|Alloc Ratio|
|---------------|--------|-----|---------|-----------|
|LeftJoin_Manual|29.02 us|1.00 |65.84 KB |1.00 |
|LeftJoin_Linq |15.23 us|0.53 |36.95 KB |0.56 |


Also β€” .NET Conf kicks off today!
Don’t miss it: https://www.dotnetconf.net/ πŸŽ‰πŸŽ‰πŸŽ‰
πŸ”₯3❀2πŸ‘1
😁5πŸ‘1
😁6🀣2❀1πŸ‘1
😁3πŸ‘1
😁3πŸ‘1
Gen Z/Gen Alpha programming language 😁

Repo for the strong of heart 😁

#belittlinglangs
🀯2πŸ‘1😁1
😁4πŸ‘1
😁6πŸ‘1πŸ‘»1
πŸ‘5πŸ”₯3😁2🀣1
😁5πŸ‘1
πŸ’―4πŸ‘2😁1
You are absolutely right!

#tomgauld #ai #suggestion_box
😁5πŸ‘1
😁8❀1πŸ‘1
Have a great week at work!

#mondaymeme #dev
πŸ‘3😁2❀1πŸ‘»1
πŸ‘2😁2πŸ’―2
Not sure why it got closed though 😁

#github
😁4πŸ‘1