Category: Code


Refactoring

Neo4j basics

Here’s a fantastic video covering the basics of the Neo4j Graph database being used from .NET, including a primer on Graph databases.  He shows how he built a ASP.NET MVC app, with a Neo4j backend, all running in Azure. This isn’t in POC; it’s a production system. Also, unlike most graph DB talks, it’s not a social network!

I love the cypher syntax,

Match me –[:LIKES]->activity<-[:LIKES]-person

Beyond fluent, it’s a pictorial language where you just draw arrows to represent a query.  Amazing.

Tatham Oddie – Neo4j in a .NET world from NDC Conferences on Vimeo.

As you know, Visual Studio’s “Clean Solution” doesn’t always delete everything from your bin and obj folders. Wouldn’t it be awesome if you had a bulletproof way of deleting all your bin and obj folders in your solution just by typing “DeleteBinObj” in your Package Manager Console? Now you can! Here’s how:

In your Visual Studio solution folder, create a file called “DeleteBinObj.ps1” that includes this code:

##########################################################
# PLEASE READ:
# 
# This script will be loaded by Visual Studio only when
# the solution is loaded therefore any changes you make 
# to it will not be effective until after you exit Visual 
# Studio and reload the solution.
##########################################################
function global:DeleteBinObj()
{
	Get-ChildItem .\ -include bin,obj -recu -Force | remove-item -force -recurse
}

In Visual Studio, go to your Solution Items folder (or create one) and Add Existing Item, pointing to the DeleteBinObj.ps1 file you just created.

Now close and reopen Visual Studio and load your solution.

In the Package Manager Console, enter the command

DeleteBinObj

If you refresh your projects, you’ll see that the bin folders are gone and the obj folders are gutted (sometimes a couple TemporaryGeneratedFiles linger in the obj directory).

Enjoy!

Good old Check-In Pending Changes window in Visual Studio 2012

Here’s how to get the Check-In window with the (overwhelmingly preferred) style of Pending Changes (circa VS2010) to work in Visual Studio 2012

This new check-in window is called using the TF.exe’s “checkin” command, but you can create an External Tool to easily call it with a menu shortcut, here’s how you set it up:

Go to Tools –> External Tools… –> Add, with these values:

Title:                      Checkin (or any name that you want displayed in the menu)

Command:          C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\TF.exe (this is the default VS install location on Windows x64)

Arguments:        checkin

Initial directory: $(SolutionDir)

Like this:

pending1

Then you call it from Tools –> Checkin, like this:

pending2

(Be aware that it takes a few seconds for the window to popup and you won’t get an hourglass or anything telling you it’s launching)

Enjoy!

BundleConfig

Bundle virtual-paths should not be duplicated, otherwise the dupe will overwrite the contents of the previous entry. To add more than one file to a bundle, wrap them in the params in the Include method.

For example, in BundleConfig.cs RegisterBundles, this:

bundles.Add(new StyleBundle("~/bundles/css").Include("~/Content/xxx.less"));
bundles.Add(new StyleBundle("~/bundles/css").Include("~/Content/yyy.less"));

Needs to be this:

bundles.Add(new StyleBundle("~/bundles/css").Include(
                    "~/Content/xxx.less",
                    "~/Content/yyy.less"
                ));

Also, the bundle virtual path depth should be the same as the depth of the file you are referring to (4 in the example below). If you don’t do this, relative paths in your less/css will fail.

	bundles.Add(new LessBundle("~/Content/xxx/less/yyy").Include("~/Content/xxx/less/yyy.less"));
© 2017 Robert Corvus