Hello World BuildProvider

These REALLY come in handy for simple little things.  I love CodeRush, can't live without it.  I like the mnemonics, ps+space generates a string property.  I also like to gen stuff from a database but for maintenance tasks or for some fine grain tools, I have no need to generate a full fledged framework to access the data. 

This is where ActiveSnippets come in, the ability to generate some code inline with whatever you're coding from details in the database.  I had a need this morning for a csharp method that selects a row from the database by primary key and returns a datatable.  It needed to be written quickly.  I got to thinking though that I always write methods for that purpose, quick little one off methods to get data out of the database.  So in about 10 minutes I created the CodeSmith template that generates the csharp method to hit the database and return a datatable with the results.  In the spirit of CodeRush mnemonics, I hooked up the template to the alias sdtft which indicates that I want to select datatable from table.

Now all I do is type this within the class I want to place the method:

Sdtft my-connection-name.dbo.the-table-i-want-data-from

Kick off the ActiveSnippets key pattern CTRL+E, CTRL+E and voila, I have a ready to go method generated for me, complete with connection string.  Here are the files:


 

CSharpSelectFromMethod.zip (7.85 KB)
 
Author: , 0000-00-00