Thanks to reader EricEJ I have added an extension method to SqlCommandFilters which means instead of coding the call like this


// Explicit usage
SqlCommandFilters.Parameters.Parameterize(ref cmd);

// you can now call it like this

// Extension method on SqlCommand
cmd.Parameterize(false);

// To do so requires two changes to the Parameters class

// first you need to modify the class definition to be static

//was public class Parameters

public static class Parameters

// And then you need to add the extension method itself.

public static void Parameterize(this SqlCommand cmd, bool reparse = true)
{
	Parameterize(ref cmd, reparse);
}

And just like that SqlCommandFilters is now an extension method on SqlCommand class!

I will be checking in the change (and the change to the test app) to GitHub when I get back from family holiday.

WP Twitter Auto Publish Powered By : XYZScripts.com