I know I should be able to crank out an instance of a custom Community Server Data Provider in my sleep, but I’m a wuss and find it tedious, even though we’re only talking about two lines of code. I seem to have to type those two lines pretty frequently, too, so today I created a quick CodeSmith ActiveSnippet to do it for me.
DBVTDataProvider dp = DBVTDataProvider.Instance();
userPurchases = dp.GetUserPurchases(userID);
With my CodeSmith ActiveSnippet I type
then Ctrl-E, Ctrl-E and I have my instance code written up to the GetUserPurchases(userID) part. A cool minor functional point about this snippet is that the cursor is at the end of “dp” when the snippet creates the code, so typing “.” with no additional cursor movement displays Intellisense right away.
The CodeSmith template has nothing interesting going on other than the logic to optionally return an object for those times I need to use an ExecuteNonQuery command.