LINQ

Functional programming with Linq — Enumerable.OfType

Of all the meth­ods avail­able on the Enu­mer­able class, OfType<T> is arguably one of the most use­ful and yet under uti­lized method. For exam­ple, you have a list of Cat and Dog objects, all inher­it­ing from a com­mon Ani­mal class, but occa­sion­al­ly you want to per­form oper­a­tions on only the dogs or cats, and that’s …

Func­tion­al pro­gram­ming with Linq — Enumerable.OfTypeRead More »

NHibernate 2.1.0 GA with LINQ to NHibernate and FluentNHibernate

I ran into a ver­sion­ing prob­lem when I tried to use the lat­est ver­sion of Flu­entNHiber­nate with the lat­est ver­sion of LINQ to NHiber­nate because LINQ to NHiber­nate is built using a lat­er ver­sion of the NHiber­nate bina­ries. After doing a lit­tle search, I found a ver­sion of NHiber­nate which both LINQ to NHiber­nate and …

NHiber­nate 2.1.0 GA with LINQ to NHiber­nate and Flu­entNHiber­nateRead More »

Functional programming with Linq — Enumerable.Range

In my Learn­ing F# posts you prob­a­bly saw how you can gen­er­ate an int array like this: this returns 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. This is pret­ty cool, and for­tu­nate­ly, you have some­thing very sim­i­lar­ly in C# with Enumerable.Range which you can use by sup­ply­ing a start­ing num­ber and a …

Func­tion­al pro­gram­ming with Linq — Enumerable.RangeRead More »

Rx framework — IObservable<T>.Retry

As Wes Dyer put very ele­gant­ly: Retry is to Repeat as Catch is to Con­cat Ok ok, I know that’s not an exact quote, but I’m sure this is what he intend­ed to say in the first instance :-P Any­how, the IObservable<T>.Retry method has all the same fea­tures of its Repeat sis­ter method, in that: …

Rx frame­work — IObservable<T>.RetryRead More »

Rx framework — IObservable<T>.Repeat

Hav­ing looked at a num­ber of exten­sion meth­ods in Rx which allows you to com­bine two observ­able col­lec­tions in some way, name­ly: Zip Merge Com­bineLat­est Con­cat Catch OnError­Re­sume­Last There are also exten­sion meth­ods which allow you to repeat­ed­ly sub­scribe to the same observ­able col­lec­tion, the suit­ably name IObservable<T>.Repeat method. If the repeat­ed observ­able col­lec­tion is …

Rx frame­work — IObservable<T>.RepeatRead More »

Rx framework — IObservable<T>.Catch and IObservable<T>.OnErrorResumeNext

Like IObservable<T>.Concat, the IObservable<T>.Catch exten­sion method con­cate­nates an observ­able col­lec­tion with anoth­er. How­ev­er, unlike the Con­cat method where the sub­scrip­tion to the sec­ond observ­able col­lec­tion hap­pens after the first had com­plet­ed, in the Catch method the sub­scrip­tion to the sec­ond col­lec­tion hap­pens after and only after the first had except­ed! Which begs a very good …

Rx frame­work — IObservable<T>.Catch and IObservable<T>.OnErrorResumeNextRead More »

Rx framework — IObservable<T>.Concat

Yet anoth­er exten­sion method to com­bine two observ­able col­lec­tions, this time we have IObservable<T>.Concat which is very sim­i­lar to IObservable<T>.Merge, but cru­cial­ly, when you con­cate­nate one observ­able col­lec­tion to anoth­er, the sub­scrip­tion to the sec­ond observ­able col­lec­tion hap­pens after the first had com­plet­ed! Here’s a quick illus­tra­tion of how the two meth­ods dif­fer: As you’ve …

Rx frame­work — IObservable<T>.ConcatRead More »

Rx framework — IObservable<T>.CombineLatest

The IObservable<T>.CombineLatest exten­sion method is very sim­i­lar to IObservable<T>.Zip and IObservable<T>.Merge in that it com­bines two observ­able col­lec­tions and returns a new one. Unlike IObservable<T>.Merge, IObservable<T>.CombineLatest does not require the merged observ­able col­lec­tions to be of the same type. Like IObservable<T>.Zip, IObservable<T>.CombineLatest com­bines ‘pairs’ of val­ues from the two observ­able col­lec­tions, but unlike Zip when …

Rx frame­work — IObservable<T>.CombineLatestRead More »

Rx framework — IObservable<T>.Merge

In my pre­vi­ous post I used the IObservable<T>.Zip exten­sion method in the Drag-and-Drop exam­ple, which takes two observ­able col­lec­tions and runs a func­tion over them to return a new observ­able col­lec­tion of poten­tial­ly a dif­fer­ent type. But what if you just want to sim­ply merge the two observ­able col­lec­tions into one stream? Well, Rx API …

Rx frame­work — IObservable<T>.MergeRead More »

Linq Over Events — Playing with the Rx Framework

As you may have read about on numer­ous MVP’s blogs already, there’s an ongo­ing research project at Microsoft’s DevLabs called Reac­tive Exten­sions for .Net (Rx) which intro­duces a push-style dual­i­ty (equal and oppo­site) of the tra­di­tion­al pull-style enu­mer­a­tion using Linq. Erik Mei­jer gave a 30 mins intro­duc­tion to the reac­tive frame­work in this video, I …

Linq Over Events — Play­ing with the Rx Frame­workRead More »

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close