Terrance A. Snyder

The Great Wave at Kanagawa
Information Architect, .NET Developer, Business Intelligence Developer, SQL Server Developer

Windows Workflow Foundation v4 Clear Instance Tables

Sometimes you have to do what you have to do.

delete from [System.Activities.DurableInstancing].InstanceMetadataChangesTable
delete from [System.Activities.DurableInstancing].InstancePromotedPropertiesTable
delete from [System.Activities.DurableInstancing].InstancesTable
delete from [System.Activities.DurableInstancing].KeysTable
delete from [System.Activities.DurableInstancing].LockOwnersTable
delete from [System.Activities.DurableInstancing].RunnableInstancesTable
delete from [System.Activities.DurableInstancing].ServiceDeploymentsTable
delete from [System.Activities.DurableInstancing].SqlWorkflowInstanceStoreVersionTable

Securing Stored Procedures via Encryption

Been researching ways to secure stored procedures on shared hosting providers to prevent prying eyes from peeking at code bases. It turns out it is really quite simple with the “WITH ENCRYPTION” option and prevents anyone from decrypting it so long as the stored procedure size is over 4kb.

Best way to make sure your stored procedures are over 4kb? How about ASCII art?

...............................   ..............................................
................................................................................
.........................................+......................................
............................. ....,......:?.....................................
......................... .... ...?.......~+........ ...........................
... ....................... .....~?.......=:=?..................................
... .............................~:.......,~+......... .........................
... ............................?,:=........,,.....  . .........................
.............................. ...::.....ZO..+:.,...............................
............................. ......I...:~+.~I7:,...............................
...........................    ......=.$,,,,$I+=:...............................
...........................  .... ..,..,7=.O=$===,.7:...........................
.................................. ..:=Z.?:,.,~=?7=7I~.................. ...  ..
............................. ........=:?,IZ.:??O,II+I$=........ ...... ....  ..
.......................................$~?I=+=I7I77+7,I=~.......  .....  .....
................................ .....:~+I.+I=Z~?=II,7,+$=....................
......................................7O=D+:Z7,.,+Z+I~++:=......................
......................................8N7NI:.,.:~+Z++??+7=:,.... ..........:....
.....................................,I8ZO$Z:...==7I+7~$,:=8.... ...... ..:O....
......................................I7I?==7~,+:$$??~?,~I=:,?....... ...~+:....
.....................................~7=:?,+Z:=OO:~+I$~~7,~?7.:~........:I=.....
.....................................:??..:~+Z7?~?,7I.+=?,,..:::,......:=?......
......................................~:...I~,O,7~=7:~$~:,:~+=,.??...:,+=.......
......................................,,.:OO7+$?~~=??+=?=?,~,.,,:Z.,=,I=.....  .
.........................................7$I+I??$:=7$7$+:..:ZI+,,..~=$.,........
..................................  ....I$O$IZ=++=II=O:=7=?..~..,:=$O...........
.......................................:O$Z$:N==I?===$7=::,.:II$+..Z,...........
.......................................?I$$:IO=$+?ZZ?=ZO~=I=+.:.,,,~=...........
.............................  . .....~I~7$7I8:.,,?+:7+O?~,.,~,:~+?$7...........
...........................    ..... .I7:~,.Z=:==?7~+I+Z~:==OI:..,,,,,..........
......................... ............:,..,,$7?7~=+?,=$7$?=,::..=~==I:..........
.................................  .........O::~???+==$O8:~::,...+NO7...........
............................................7=I=??$7:I7Z+7~.7ZOO$O8Z$,..........
............................................??+:=I+$I+I77$$Z?Z7ZOZ?DOZ=,.... ...
........................  ..,:I..,.........,8~,777:77+7I$ZD$D$I+77$ZZZ$.........
.............................,7~,.,7~...,,,Z8:$=8+IO7?7+N88$7O8O$I77I?Z7........
..................................=I+,.,.:D~$??+I77O7+N88Z$::?$O$??==I++........
.......................................,I$8O8I$,I?+7Z+7DO78O7ZO88?:~:.:,..... ..
......................  ..............7.+ION$~Z~+I++~I+D78++=~=$I8,....:,.......
..........................  ......=?.?IN,?$++,IO?I~,:=??=7$,:,,++O7?.,O7...  ...
................... .............:==,,,7+I7.+I~DI?7$?.,,.$8,..~=?Z?II,,.........
......................  ........,.O::I8:~?$,.:+7Z+=IZ==??7D+,:+I+,::I+I.........
................................:.?,7.,7$8?$+?.=?:7?II.:I?+.~,=+O==Z~.:+... ....
.................... .........7=~7$:?:$=$~=:,~.I=:I??7:~?=~.:,=+:~IO,?~,........
..........................7=.7~+?I+77=:=$,7~::I7,,??=7~.7++=~~=?$+$~I..::,......
.. .....................:+$.7...,.:.,:?7I?+,7I,=$:+?~~,=,~,..~IZI+I~~,=.~.......
.. .. ..................7~,...........7I$7?~:,Z77+?+:+IZZ7~.=I$=8+?+7I,:~.......
...............  ....................=?NIII?+:~::7==~+,.?,..~+78:::,,,.,.+......
...............   ...................:7MZ?::I7+I~I?~?=~+$++I~$+???7$7+.=~=:,....
..............      ........... .......I~=?:.,.$$I::I+~:,~:++$,...I.......:,....
...................  .................~?+~.??==+~O7?7I~?I,=??Z~:=:,.,+,...,.....
........................... ........,....Z+:~,?Z?O?I~?$7I=?+=7IOO+7~..:.........
.................      ...........,,::+=.?I$?==:,Z,?:=.8,.=$I7O+,,:,,~:.........
................. ..... ........,..~~:=+::=,,ZI~I7Z.~I+ZZI~7Z+~+~77$$I..........
.............. . ....:..,....,.=:.~+:?=I,,::..,=Z=~?,$I+.8Z:D$~=IZ$,.:.... .....
..........   .. ......:,.:=.=.,.,::..,:,7?~:.,:~~Z7.+,?~Z,?=:+I?+:,+=.:,..,.  ..
.............. ,..,,,,,:,,,,..,,::,:,:~~?I=+=~=,I7=::::~.,$.===,=~:?=.+.:.......
....................,..:::.,,,.,::,::~=~:~?:,,~+7=~:====:,~I?I,==~?=?,,.~:,.....
..............,..,.,~~:=:,,:,.=,:,,,,:~~,+?:II~?,?~=~,~~:~?I,~=:++,,,~.~.:,:,...
...........,.,.....~,:,,:,.:?::~.~,~~.,~,?:=I?==~,,7:~?~~~==~+~=7,,,,:.::,......
.....   ......,..:.=.:..,,,=.::~:,.::,.:.~~,,::7,:,=,~,+~??,=:=+:~:.::.:~..,....
.....   ...:,,.,,,.:.,,.,~:~,~,~?:.~.::,,,,:,~~,::.=::,,,7:,,,,~,::~~,~,,,,.....
.......................,.:,,,~:~...:,:,,~,:.,~~=::.:~,,...,,,..,:..:=,.,:,,.. ..
......... .................:.,,,...,....,,,.,:,:~:.,...,=..:..:.:.,,,..,,,......
........................................,:...:,.,.............,.................
.............   ..   ........................ .. ..... .....,.:,............
............  ...........        .............     .............................
........................................ ............................. .........
................................................................................

DLR in .NET

Bet this starts freaking people out sooner rather than later. I personally love it. Go duck typing. (and unit tests).

Looking at Ayende’s potential DB solution over Lucene and it’s peek my interest. I remember writing so much reflection code for dynamics and JSON, now its more or less out of the box.

using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Dynamic;

namespace Dynamics
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            dynamic d = new Bag();
            d.Age = 25;
            d.Name = "Terrance";

            Action<dynamic> hi = (self) => Console.WriteLine("{0} is {1} years old!", self.Name, self.Age);
            d.SayHello = hi;

            // result = "Terrance is 25 years old!";
            d.SayHello();

            // result = "Terrance is 25 years old!";
            SayHelloAgain(d);
        }

        void SayHelloAgain(dynamic d)
        {
            d.SayHello();
        }
    }

    public class Bag : DynamicObject
    {
        Dictionary<string, object> _properties = new Dictionary<string, object>();

        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            result = _properties[binder.Name];
            return _properties.ContainsKey(binder.Name);
        }

        public override bool TrySetMember(SetMemberBinder binder, object value)
        {
            _properties[binder.Name] = value;
            return true;
        }

        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            dynamic target = _properties[binder.Name];
            bool match = false;
            result = null;
            switch (args.Length)
            {
                case 0:
                    target(this);
                    match = true;
                    break;
            }
            return match;
        }
    }
}