St. Louis Day of .NET 2013

This post is long overdue, as the 2013 Day of .NET took place almost two months ago.  I set aside my notes while I waited for presenters to post their session materials online… and then I forgot about it.  So, without further ado, here are my notes from the event:

DAY 1

Session: Entity Framework in the Enterprise

Presenter: http://www.twitter.com/scottkuhl
Session Materials: https://skydrive.live.com/?cid=b11213b176cf5d39&id=B11213B176CF5D39%2148854

Getting Started with Entity Framework
     http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc (EF6 and MVC5)
     http://www.asp.net/mvc/tutorials/getting-started-with-ef-5-using-mvc-4
(EF5 and MVC4)

SQL Server Data Tools 
     Use LocalDB 
     Allows for loading of test data 
     Allows for data to be "reset" to a known state 
     Remember to check the "Target Connection String" in the DB project properties dialog

Entity Framework Power Tools v.4 (Beta)
     http://msdn.microsoft.com/en-us/data/jj593170.aspx
     Provides reverse engineering of databases into code-first classes, using the Fluent API

Unit Testing
     Entity Framework 6 has support for mocking frameworks
     Allows you to create your own test doubles
     It is recommended to test against a "real" DB for Last Mile test and performance tests

Audit Tracking
     SQL Server Change Data Capture
          Available in SQL Server 2008 and beyond (Enterprise Editions only)
          Uses change tables that mirror structure of tables being tracked
          Populates the change tables by analyzing the transaction log (not via triggers)
     If using EF natively
          Override the "SaveChanges" methods
          Loop through the contents of the "ChangeTracker" collection (saving the details along the way)

Performance Tracking
     Entity Framework 6 includes/allows logging of SQL statements and execution times
     Other useful tools include NLog and Glimpse

Session:  Introduction to MongoDB

Presenter: http://www.twitter.com/bradurani

Background
     6th most popular database in the world, just behind PostgreSQL and DB2
     There are drivers for many languages, as well as a LINQ provider.
     Data stored as BSON (binary JSON)
     Everything is case-sensitive

Benefits
     Speed – basic queries are much faster than SQL DBs
     Rich Dynamic Queries – not as limited as other NoSQL DBs
     Easy Replication and Failover
     Scalability
     Automatic Sharding

Limitations
     No transactions
     No joins
     RAM intensive
     No referential integrity
     "Eventual consistency" – periods of inconsistency usually measured in milliseconds

UIs
     MongoDB shell (command line)
     Various GUI tools

Querying
     Can query by regular expression
     Can return entire records or specific fields

Object IDs
     Object IDs (auto-generated unique IDs) contain timestamp of record creation.
     Timestamps contained in Object IDs can be retrieved.
     Can define your own IDs, which is useful for sharding

Indexing
     Can index pretty much any part (or parts) of a record, up to and including the entire record

Replication
     If the primary fails, a secondary is auto-elected as the new primary

Session:  Modern Web Diagnostics with A Glimpse into ASP.NET

Presenter: http://www.twitter.com/anthony_vdh

Background
     Installed via NuGet
     New versions are released approximately every two weeks

Functionality
     Gives insight into ASP.NET, WebForms, and others
     Gives diagnostics on networks, databases, page lifecycle, viewstate, and more
     Can trace individual users
     Can be enabled/disabled in various ways (cookies, roles, etc)
     Keeps the history of the last 50 requests, so recent requests can be examined after they occur

Platform Support
     Cross browser (last versions of browers supported) and cross platform
     Support exists for tracing NHibernate, Entity Framework, MVC, WebForms
     WebAPI support is on the way (not there now)

Session:  Parallelism in .NET

Presenter: http://www.twitter.com/mulbud
Session Materials: http://geekswithblogs.net/NewThingsILearned/archive/2013/11/21/st.-louis-day-of-.net-2013.aspx

Threads
     More threads means more memory usage and more context switching
     Developers need to find the appropriate balance between the # of threads and resource usage
     Available since .NET 1.0

ThreadPool
     Similar to database connection pooling
     Resources are managed much better
     Available since .NET 1.0

Parallel Linq (PLINQ)
     Example: from r in object.AsParallel() select r
     When using this, you must watch out for shared resources, and lock them correctly

Parallel Library
     Provides the parallel For, ForEach, and Invoke methods
     Allows processing to be stopped via the "ParellelLoopState" delegate

Tasks (TPL => Task Parallel Library)
     The most complex option to use, but also the most flexible
     Can be used "as needed"; they are not bound to the loop processing of the Parallel Library
     Allow parallel processes to be stopped
     Necessary for the use of Await/Async

Await/Async
     See the slide deck for the details of how "await" works
     Async methods must return Task
     Await can always be used on a Task, whether it is "async" or not
     When calling an async method, always await it (best practice)

Debugging Support
     When a breakpoint is hit, all running tasks stop
     Several parallel debugging windows are available under the Visual Studio "Debug" menu
          Tasks – shows all running tasks; click a task to go to the currently executing statement
          Parallel Stacks – visual display of running tasks and the call stack; click a task to see the current statement
          Parallel Watch – allows watching a variable in a particular task

Session:  A Deeper Dive Into Xamarin.Android

Presenter: http://www.twitter.com/benjamminstl or http://www.twitter.com/rendrstl
Session Materials: http://www.slideshare.net/BenjaminBishop1/deep-dive-xamarinandroid

Tools
     Xamarin Studio (native) – not free
     Xamarin Studio plug-in for Visual Studio – not free
     PhoneGap

Recommended components for easing cross-platform development:
     Xamarin.Mobile – abstracts your code for location/photos/contacts across all platforms
     Xamarin.Social – similar to the Mobile component, only for social services
     Xamarin.Auth – makes OAuth easier to use
     RestSharp
     SQLite.NET
     JSON.NET

Components for Android
     Google Play Services
     Backward compatibility component (for supporting older versions of Android)

Frameworks
     MvvmCross
     MonkeyArms

Notes about developing for Android
     Turn on Hardware Acceleration in the application manifest
     Activity (app) lifecycle events reminiscent of ASP.NET page lifecycle events (or Windows 8 app events)
     Lots of XML involved in app creation
     "Layouts" are used to create app UIs.  Reminiscent of XAML.

Experience
     Android SDK is more robust and complicated than iOS
     Not as prescriptive in UI/design
     Device fragmentation is a challenge
     Emulators are poor; use a real device for testing
     Platform is more innovative than iOS, but not as polished

DAY 2

Session:  All You Ever Wanted to Know About Hadoop

Presenter: Matt Winkler

Written in Java (runs on the JVM)

Installation Options
     Single computer
          HDInsight (Microsoft’s implementation) can be installed from Web Platform Installer
     Cluster
          Various installation packages
     Cloud
          Azure – multiple nodes running HDInsight can be easily provisioned
          Amazon Cloud Services

MapReduce is the tool for querying data with Hadoop
     White Paper: Data-Intensive Text Processing with MapReduce (http://lintool.github.io/MapReduceAlgorithms/)
     MapReduce can be thought of as the assembly language for Hadoop.

Extensions to MapReduce
     Most of these compile down to MapReduce packages

     Hive – SQL-like query language
     Pig – another query platform
     SCALDING – Scala-like query language.  The syntax is LINQ-like.
    
Other Tools
     SQOOP – used for loading traditional RDBMS data into Hadoop
     STORM – tool for complex event processing
     OOZIE – Workflow Management for Hadoop

Session:  Building A REST API With Node.js and MongoDB

Presenter: http://www.twitter.com/leebrandt
Session Materials: https://github.com/leebrandt/ReSTNodeMongo

Useful Node.js packages (similar to NuGet packages in .NET)
     Restify – adds REST capabilities
     Underscore
     Toaster – UI functionality
     Moment – date handling
     MongoDB – MongoDB client tools

WebStorm from JetBrains is a recommended Javascript editor ($49 individual developer license)

http://education.mongodb.com – offers *free* online course on MongoDB

Session:  Starting with Code-First Entity Framework

Presenter:  http://www.twitter.com/mulbud
Session materials: http://geekswithblogs.net/NewThingsILearned/archive/2013/11/21/st.-louis-day-of-.net-2013.aspx

Create a class that inherits from DbContext… within that class, define the tables to create

Create classes to represent each table

Database is created automatically the first time that it is accessed

Handing DB changes
     1) Update the code
     2) Via attributes, databases can be set to drop/create always, drop/create only when the model changes
     3) Database migrations are another option

Database Migrations
     Package Manager Console can be used to generate classes to handle migrations. 
     Alternately, create a Configuration class in a Migrations folder
     Use the Configuration class with the MigrateDatabaseToLatestVersion class in SetInititalizer method of the Database object.
     Or, if you choose not to trust the auto-migration, generate a TSQL script to perform the migration.
     TSQL scripts can be generated from the Package Manager Console

ExpressProfiler is a simple SQL profiler… find it on CodePlex.

Session:  Introduction to Knockout.js

Presenter:  http://www.twitter.com/johnvpetersen
Session Materials: https://skydrive.live.com/?cid=4b5cb012cf825f0c&id=4B5CB012CF825F0C%213211&authkey=!APKGSzHxmC91400

What is it?

     JS library for dynamic web-based UI’s
     Applies MVVM to automate data binding

Concepts

     Declarative bindings
     Dependency Tracking
     Templating
     Automatic UI Refresh
     Dependency Injection

MVVM (Model-View-ViewModel) Pattern

     Combination of the MVC/MVP patterns
     View – UI and UI Logic, talks with ViewModel and receives notifications from ViewModel
     ViewModel – Presentation Logic, talks with View (data binding and commands (bi-directional), notifications [to View]) and Model (bi-directional)
     Model – Business Logic and Data, talks with ViewModel

Data Binding

Data

     Knockout.js implements the ViewModel

var myViewModel = function() {

      var data = { productid: 1, productname: "shoe", productprice=1.99 };

          this.property = ko.observable("value");   

          this.products = ko.observableArray(data);     // "data" is an array of products

          this.handler = function(data,event) {}

          }

     ko.applyBindings(new myViewModel());

     "ko" is the global identifier for Knockout

Binding

Attributes of HTML elements are bound to the ViewModel properties (also CSS and conditional logic like "foreach" and "if")

     <input data-bind="value: property" />

     <button data-bind="click: handler"></button>

     <tbody data-bind="foreach: products">

          <tr><td><input data-bind="value: productid"></td></tr>

     </tbody>

Individual elements can be bound to more than one property (example: "text" bound to one thing, "visible" bound to another)

Session:  Real World Azure – How We Use Azure at Swank HealthCare

Presenter: Brad Tutterow

SQL in an Azure VM vs SQL Azure Database
     VM option does place your database in the cloud
          BUT
     VM option still requires you do to your own backups/restores/server maintenance
     VM option does not provide for scalability of a "true" cloud DB

     SQL Azure DB is Microsoft’s preference

DB Changes that were needed for SQL Azure Database
     Remove Cross-DB triggers
     Remove file groups in CREATE scripts
     Account for cloud-based SQL being a limited subset of full SQL
          Example: No "USE" statement, so scripts may need update
     Modify backup strategy (no traditional Backup/Restore in the cloud)

Always run two of every Web Role
     Roles are frequently recycled by Azure
     If only one Role exists, your site is down when the Role is recycled
     If two Roles exist, Azure will switch between the two as needed, and not recycle both at the same time

Deployment best practices
     Determine which application settings (web.config) need to be changed at runtime
          Move those settings to Azure settings
          Everything else can stay in the web.config
          Changing web.config in production doesn’t "stick"… Role recycle will wipe the changes
     Create deployment packages
          Role recycle will wipe updates if not deployed via a package
     Make no assumptions about what is available on the server
          You must deploy everything your app needs (all NuGet packages, etc)
          Role recycle produces fresh copy of Windows

Database updates handled via EF Code-First Database Migrations
     Question: How would updates be handled without Code-First, or with some other ORM?

Pain points
     Local Azure emulator is unreliable and inconsistent
     No effective way to do QA on-premise (means more cost for a QA environment in Azure)
     Learning curve (not too bad)
     Azure SDK versioning (keeping everything in sync… updates are quarterly)
     EF migrations and Azure SQL (scripts don’t always work in Azure; need to be edited)

Good things
     Uptime and reliability
     Buy-in from sales/operations/infrastructure
     Enforced best practices for design and deployment
     Pristine/clean production environments
     QA/Prod environments are identical
     No IIS or Windows OS management
     Easy deployments

TO-DO LIST

  • Investigate SQL Server Change Data Capture as a replacement for auditing with triggers.
  • http://virtualboxes.org/images/
  • Check out DurandalJS (mentioned in several sessions)
  • Check out Twitter Bootstrap
  • Check out LESS
  • Check out Glimpse
  • Think about what could be done with a large OCR corpus and Hadoop 
Advertisements

St. Louis Day of .NET – S.O.L.I.D.

This is part of a series of posts containing my notes from the sessions I attended at the 2011 St. Louis Day of .NET conference.

This series does not attempt to give complete accounts of the information presented in each session; it is just a way to capture the bullet points, notes, and opinions that I recorded while attending the conference. I have previously posted a list of all of the session materials and sample code that I have been able to find online, so if you are looking for a more precise account of a session, try looking there.

My favorite presenter at this year’s conference was Steve Bohlen.  He presented at three session; I attended two: “Taming Dependency Chaos with Inversion of Control Containers” and “Refactoring to a SOLID Foundation”.  Both were excellent.  Following are my notes from the SOLID session.

Single Responsibility Principle

There should never be more than one reason for a class to change.  Each class should do one thing.

Open-Closed Principle

Software Entities (classes, modules, functions, etc) should be open for extension, but closed for modification.

Instead of this:

     public class Report
     {
          public void Print()
          {
          }
     }

Use this:

     public class Report
     {
          public virtual void Print()
          {
          }
     }

So that you can do this:

     public class Report2 : Report
     {
          public override void Print()
          {
          }
     }

In this case, the old working code ("Report" class) still works, and we have also added new functionality ("Report2" class).

Liskov Substitution Principle

Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it. (Polymorphism; important part highlighted)

Instead of:

     public class LetterReport
     {
          public virtual void Print()
          {
          }
     }

     public class TabloidReport : LetterReport
     {
          public override void Print()
          {
          }
     }

Here, TabloidReport overrides a particular kind of report (LetterReport).

Do this instead:

     public abstract class Report
     {
          public abstract void Print()
          {
          }
     }

     public class LetterReport : Report
     {
          public override void Print()
          {
          }
     }

     public class TabloidReport : Report
     {
          public override void Print()
          {
          }
     }

Now, the base class for the reports is truly generic (it’s not a particular kind of report).

Interface Segregation Principle

Clients should not be forced to depend upon interfaces that they do not use.

Do not build catch-all interfaces like this:

     public interface IDataAccess
     {
          public void SetConnectionString();
          public void Connect();
          public Data GetReportData();
     }

Instead, interfaces should "build upon" other interfaces, as such (interface composition):

     public interface IDataAccess
     {
          public void SetConnectionString();
          public void Connect();
     }

     public interface IReportDataAccess : IDataAccess
     {
          public Data GetReportData();
     }

Now, classes can select the interface that makes the most sense, rather than getting a single interface with everything.

Dependency Inversion Principle

High level modules should not depend on low level modules.  Both should depend on abstractions.  Abstractions should not depend upon details. Details should depend upon abstractions.

This is where dependency injection and object composition comes into play.  No easy code example to give here.

St. Louis Day of .NET – jQuery Plug-ins

This is part of a series of posts containing my notes from the sessions I attended at the 2011 St. Louis Day of .NET conference.

This series does not attempt to give complete accounts of the information presented in each session; it is just a way to capture the bullet points, notes, and opinions that I recorded while attending the conference. I have previously posted a list of all of the session materials and sample code that I have been able to find online, so if you are looking for a more precise account of a session, try looking there.

One of the better sessions I attended at this year’s conference was Ian Robinson’s “Building jQuery Plug-Ins”.  Too many sessions I attended this year skipped the how-to-get-started and jumped right into examining the code of a finished product.  This session, on the other hand, stepped through the entire process of building a jQuery plug-in.  Here are my notes from the session:

The Process

  • Wrap business logic with plug-in logic
  • The business logic can stay largely the same
  • Modify to inject settings and context
  • Modify for safety and to play well with others
    First step

Wrap in a closure…

(function($) {
     // ahh… safety
})(jQuery);

This structure ensures that our code doesn’t conflict with others (takes it out of global scope and defines the plug-in’s own scope).  It also ensures that when a dollar sign ($) is used in the body of this code, it means jQuery (and not anything else).

http://nathansjslessons.appspot.com/ (What’s A Closure?)

Define the Plug-in

No selecting needed:

     $.fn.myPlugin = function(options) {…};

Select and return (chain):

     $.fn.myPlugin = function(options) {
          return this.each(function() {
               …
          });
     };

Establish Default Options

     $.fn.myPlugin.defaultOptions = {
          speed: ‘slow’
     };

     var opts = $.extend({}, $.fn.myPlugin.defaultOptions, options);

Inject HTML Context

Options aren’t just for settings.

Inject all context through options.  For example:

     $(‘.nav’).myPlugin({
          speed: ‘fast’,
          subNavSelector: ‘li.subnav’
     });

Events

Determine if you need to enforce document.ready.  If not, let the user of the plug-in do it.

If you’re ever unbinding events, bind with a namespace first.  For example:

     $(‘elem’).unbind(‘click.Namespace’, function(){…});

Complete Example

(function($) {
     $.fn.myPlugin = function(options) {
          var opts = $.extend({}, $.fn.myPlugin.defaultOptions, options), $moduleWrap = this;
          // Iterate over all elements contained in the current context ($moduleWrap = ".myClass"???)
          $moduleWrap.each(function() {
               // Grab the element being evaulated
               var $module = $(this);
               … do something …
          })
     };

     $.fn.myPlugin.defaultOptions = { 
          speed: ‘slow’ 
          subNavSelector: ‘li.subnav’
     };

     $(document).ready(function() {
          $(‘.myClass’).myPlugin();
     });
})(jQuery);

More examples and documentation
http://css-tricks.com/snippets/jquery/jquery-plugin-template/
http://docs.jquery.com/Plugins/Authoring
http://jquery.ian-robinson.com (jQuery Crash Course)

St. Louis Day of .NET – Entity Framework 4.1

This is part of a series of posts containing my notes from the sessions I attended at the 2011 St. Louis Day of .NET conference.

This series does not attempt to give complete accounts of the information presented in each session; it is just a way to capture the bullet points, notes, and opinions that I recorded while attending the conference. I have previously posted a list of all of the session materials and sample code that I have been able to find online, so if you are looking for a more precise account of a session, try looking there.

Brad Tutterow presented The Tasty Flavors of Entity Framework 4.1, which introduced the various ways (Code-First, Model-First, and Database-First) to develop with the latest version of Entity Framework.  Here are my (rather brief) notes from the session.

  • More information about Entity Framework on Julie Lerman’s blog:  http://thedatafarm.com/blog/
  • A very good decision tree for which "flavor" (database-first, model-first, code-first)  of Entity Framework 4.1 to use can be found at http://thedatafarm.com/blog/data-access/model-first-database-first-or-code-first-ndash-update-to-data-points-column/
  • The ‘DbContext’ object was added in Entity Framework 4.1, and is the preferred object for interacting with Entity Framework.  Previously, the only option was ‘ObjectContext’.
  • If you have existing data access classes that represent your data model, you can use the code-first method for EF.  (This is Interesting… worth trying out to see how it works.  Perhaps offers another way to migrate to EF from existing code.)
  • Code-first requires *manual* creation of the DBContext class.  Then, add a connection string with a name that matches the name of the DBContext class.  On the first run of the code-first application, the database will be created automatically.  (Whoa, really?  Will have to think about how this can work in a controlled production environment.)
  • With the code-first approach, use the Fluent API if your entities (classes) differ from the data model.

.

St. Louis Day of .NET – Code Contracts

This is part of a series of posts containing my notes from the sessions I attended at the 2011 St. Louis Day of .NET conference.

This series does not attempt to give complete accounts of the information presented in each session; it is just a way to capture the bullet points, notes, and opinions that I recorded while attending the conference. I have previously posted a list of all of the session materials and sample code that I have been able to find online, so if you are looking for a more precise account of a session, try looking there.

Jeff Ayers presented a session on a very new add-on to Visual Studio, Code Contracts.  I have been reading Dino Esposito’s ongoing series of articles about Code Contracts in MSDN Magazine, and was interested in hearing another perspective on the technology.  The verdict seems to be that the technology is not quite ready for prime-time.  Here are my notes from the session..

  • Code Contracts Standard/Premium from Microsoft DevLabs is the Visual Studio plug-in that is needed to enable the technology.  Available from http://msdn.microsoft.com/en-us/devlabs/dd491992.
  • Description from the download site: "Code Contracts provide a language-agnostic way to express coding assumptions in .NET programs. The contracts take the form of pre-conditions, post-conditions, and object invariants. Contracts act as checked documentation of your external and internal APIs. The contracts are used to improve testing via runtime checking, enable static contract verification, and documentation generation. Code Contracts bring the advantages of design-by-contract programming to all .NET programming languages."
  • An example of a code contract in C# is data validation that that be defined simply by adding attributes to a method or class.
  • Looking at the above description of code contracts, an example  "coding assumption" is that an input value to a method will be between 1 and 10.  This would be a "pre-condition" for the execution of the method.  The method is decorated with an attribute that specifies the contract conditions.  The contract conditions are verified via "runtime checking".  The attributes also enable "static verfication" and "documentation generation".
  • Contracts are checked at run-time.
  • After working with Code Contracts for three weeks, the presenter believes that the tool, while useful, is not completely mature.  The session demonstrations illustrated the difficultly in working with the toolset at the present time.
  • System.Diagnostics.Contracts is the namespace to include to gain access to the code contract functionality
  • Exceptions of type "ContractException" cannot be caught.  (Perhaps something that will change in the future?)  Instead, you can specify the type of exception to be thrown when a contract is violated.  For example, you can choose to throw an ArgumentException.  Those exception types can be caught as usual.
  • Examination of the IL revealed that a lot of additional code is generated by the compiler to handle contracts.  The presenter stated that while good for producing developer feedback, contracts should not yet be included in production builds, at least for object invariant contracts.  It adds too much overhead to a running application, affecting performance.
  • The tool does not work for WCF, because the WSDL doesn’t reflect the contract feedback that is so useful to users of the service (developers).

St. Louis Day of .NET 2011 – Brief Notes on Objective-C, LINQ, and NHibernate

This is part of a series of posts containing my notes from the sessions I attended at the 2011 St. Louis Day of .NET conference.

This series does not attempt to give complete accounts of the information presented in each session; it is just a way to capture the bullet points, notes, and opinions that I recorded while attending the conference. I have previously posted a list of all of the session materials and sample code that I have been able to find online, so if you are looking for a more precise account of a session, try looking there.

I took only brief notes in sessions focusing on Objective-C, LINQ, and NHibernate, so I’m combining all of them into this post.

First up is Looking at Objective-C Through the Glass of a Typical .NET Developer, presented by Muljadi Budiman.  This session, on a decidedly NON-Microsoft topic, was filled to overflowing… needed a bigger room for this one.  Perhaps my favorite sound-bite of the conference came from this session… “does anyone think this is NOT weird?”.

  • Objective-C is a superset of C, very different from C#
  • Each class made up of two files:  header files (*.h) provide an provide interface, and source files (*m) provide the implementation
  • XCode is the OSX-based Objective-C development environment
  • Classes must be referred to with a pointer syntax.  For example, NSString* instead of NSString, or Person* instead of Person
  • Accessibility operators (@private, @public, @protected) are valid only for variables, not classes, methods, or properties.  Because of this, *any* method or property can be overridden.
  • In Objective-C, you must allocate (alloc) and initialize (init) objects.  Use "new" to alloc, init, and call constructor.  In addition, objects should be "release" when you are done with them.  If not, the objects stay in memory.
  • "Protocols" behave something like interfaces in C#
  • There are no static classes.

Next is Deliver Cleaner Code with LINQ to Objects.  Not the best choice of sessions on my part.  The material presented was fine, but it didn’t teach me much I didn’t already know.

  • Don’t use "var" just because you can.  Use it when you truly don’t know the return type until run-time.
  • When using LINQ, you can use either extension methods or LINQ queries.  Queries are typically easier for developers with database experience, but some functionality is only available via extension methods.
  • Extension methods utilize lambda expressions.
  • The compiler turns the LINQ query syntax into extension methods.
  • LINQ Extension Method Example
    var list = contacts.Where(x => x.State == "TX").Select (c => c.BirthDate);

LINQ Query Syntax Example
var list = from c in contacts where c.State == ‘TX" select c;

The last couple notes are from Lee Brandt’s session on NHibernate, titled NHibernate, Fluent NHibernate, and the Repository Pattern.  The demos given in this session mostly focused on (relatively) complex completed code.  There was no from-the-start “Hello World” example given.  So while I was able to get a general sense of what it takes to work with NHibernate, I was left with a lot of unanswered questions.

  • It looks like extensive up-front work is needed to wire up the database (create mappings, etc)
  • Unanswered question:  Is there no way to auto-generate the initial class-to-database mappings?
  • These links may be useful for future research into NHibernate:

http://wiki.fluentnhibernate.org/Auto_mapping
http://www.fincher.org/tips/Languages/NHibernate.shtml
http://stackoverflow.com/questions/278046/free-nhibernate-helper-tools

St. Louis Day of .NET 2011 – PowerShell

This is part of a series of posts containing my notes from the sessions I attended at the 2011 St. Louis Day of .NET conference.

This series does not attempt to give complete accounts of the information presented in each session; it is just a way to capture the bullet points, notes, and opinions that I recorded while attending the conference. I have previously posted a list of all of the session materials and sample code that I have been able to find online, so if you are looking for a more precise account of a session, try looking there.

Following are my notes from the PowerShell – 10 Things You Need To Know session, presented by Matt Hester.  He has posted online far more information than could be covered in one conference session; you can find that material on his blog

One thing that I felt was missing… or that I missed.. from the presentation was an explanation of how to obtain, install, and/or check for PowerShell.  For that reason, my notes jump right into the details of using the tool.

  • Besides being a script environment useful for bulk operations and task automation, Powershell also provides an interactive shell.
  • Everything in Powershell is considered an object.
  • Commands may be cmdlet, alias, or function.  A "cmdlet" is a "normal" command.  An "alias" is an alias for another command.  A "function" is a way to execute a block of commands (and can accept parameters).
  • The "|" operator routes output from one command to the input to another command.  Multiple commands can be connected. 
  • PowerShell is not always consistent about when a dash is needed (ex: "-confirm" vs "confirm").
  • You can use "providers" to access things like Active Directory and the Windows Registry with PowerShell.  (For example:  use "cd AD:" to navigate to the root of the active directory tree on the local machine.)
    Here are the specific PowerShell commands that were covered in the session.

get-command 
Show the list of PowerShell commands that are available.  This is not ALL PowerShell commands, but all *available* commands… see the next two commands for clarification.

get-module –listavailable
Show all modules that provided PowerShell commands (whether those commands are currently available or not).

import-module <modulename>
Loads a module to make its commands available to the current PowerShell session.

get-service
Lists the services on the machine.

get-help <built-in cmdlet name>
Gets information about the named command.

get-help <built-in cmdlet name> – examples
Gets information, including examples of usage, for the named command.

get-service |get-member
List available methods and properties for services on the machine.  Note that the “|” operator is used to send the output of the get-service command to the get-member command.

get-service |out-file <filename>
Send the output of the "get-service" cmdlet to the specified file (text file)

get-service |out-gridview
Send the output of the "get-service" command to a sortable/filterable GUI window. Unfortunately, the window does NOT support copy and paste.

get-service |stop-service –whatif
The "-whatif" parameter will show you what the specified command(s) will do (without actually executing those commands). In this case, the commands will in fact stop all of the services on the machine.

get-service |stop-service –confirm
The "-confirm" parameter will cause the user to be prompted for confirmation that the command should be executed.