Contents tagged with powershell

  • Using Domain Console to Migrate Entities

    Tags: nhibernate, powershell, domain console

    As I mentioned in a previous post, Jim referred to on Twitter and officially named it, we’ve been tinkering with the idea of using Powershell and NHibernate together to move entity instances between persistence mechanisms. I’m going to cover how one can accomplish this functionality using Domain Console in this post. If you prefer just looking at PS1 files, a code download is available at the end of the post.

  • A Powershell Drive Using NHibernate

    Tags: powershell, nhibernate, domain console

    Inspired by my buddy Jim’s article series on the topic of creating Powershell drives, I had lunch with him to find out more about the complexities in doing so. Inspired by my Enterprise Library-like wrapper around NHiberate, he wanted to discuss with me an idea he had for a new drive provider that would universally access databases. The more we talked (and drank margaritas) the more the idea percolated as one with merit.

    With Jim’s excellent article series as a starting point I created such a drive around “the knocks,” an NHibernate Quick Start library I created (that may be discussed later in more detail). The result appears to be something I think could be quite nifty – a command-line provider interface for any database platform supported by NHibernate.

    Here’s a preview. The following cmdlet does a few things, which will be highlighted below. Imagine this as script you’d enter at a Powershell command line.

    image

     

    1. Loads in the SQLite assembly, as it’ll be used as a database platform
    2. Sets up a drive. The parameters passed to the drive can be summarized, high level, as:
      1. domainAssembly – where the domain entities live
      2. dataAccessAssembly – where the implementations of the ISessionFactoryService and ISessionFactoryRequestService interfaces live
      3. requestServiceType – Implementor of ISessionFactoryRequestService
      4. sessionFactoryType – Implementor of ISessionFactoryService
    3. The database is then queried for a particular type of domain entity – a Geek object instance

    When this script is executed and the database-creation process executes, the SQL is shown to demonstrate the mapping has succeeded.

    image

    Then, due to NHibernate’s convenient logging features, you’ll see more SQL output in the console window reflecting the inserts and selects being performed against the SQLite database. This gives a glimpse into how the data is added to the database.

    image

    Lastly, a shot of just when the Get-Item part of the script is called.

    Once the database has been wrapped, the final call can be made, to Get-Item.

    image

    The output of this results with the objects our debug-time database-saving had completed so test data would exist. When the output streams into the console it’s obvious – we’re querying a database-agnostic NH repository library directly using LINQ at the Powershell command line.

    The first shot is of the SQL getting executed directly into the SQLite database via NHibernate.

    image

    The second is how the objects look – and how they can be interacted with – at the Powershell command line. They’re instances, object-relationally mapped directly from a database, fresh for copying (or migrating and then copying) into an RDMBS living somewhere completely different.

    image

    Hopefully we’ll have some more information on this coming up and a lot more refinement. For now though, would you think universal RDBMS access via object-specification and retrieval via generic selection would be useful?

Windows Azure Training

Looking for information on Windows Azure? I work with a great team of guys who put together the Windows Azure Training Kit. If you're doing anything with Windows Azure and you have questions, chances are pretty good you'll find what you're after here. 

My SignalR Samples

After having given a few SignalR presentations I decided to start compiling all the code in a centralized repository. Check out my SignalR Samples repository on GitHub.com

Channel 9

One of the coolest parts of my job is being able to host a Channel 9 TV show. Web Camps TV is the show I co-host with Cory Fowler. Check out our episodes on Channel 9, where we talk to Microsoft community members and engineers.