This blog post is for those folks comfortable with creating a data stream from an IEnumerable, IObservable or StreamInsight adapter data source. If you’d like more details on creating those, have a look at this blog post, which covers creating an IEnumerable ‘canned’ data source then wrapping a LINQPad context around it.
Creating a data context is very straightforward:
That’s it! Here’s what this looks like in practice. First we establish the basic class
Now we’ll go ahead and expose three types of streams. The first will be one generated from an IEnumerable.
Next, we’ll use IObservable (created via Observer.Interval) to generate a “live” stream of events:
Finally, we’ll leverage the DataGenerator sample adapter (from http://streaminsight.codeplex.com/) to demonstrate creating a LINQPad stream from an adapter.
To test, we’ll need to configure LINQPad with our assembly as a data context. To do this:
The context streams should now be visible in LINQPad, similar to the screenshot below. Create a new Query, and select C# Statements as the Language, and StreamInsight: SampleContext as the database.
Let’s dump our streams, using this LINQ code:
This will show us our enumerable and observable streams:
Finally, let’s dump out some data from our adapter stream:
That’s it – a LINQPad data context in a nutshell.