Migrator .Net Code Templates

A little while ago I posted some code samples that made the process of creating migrations in migrator .net a bit more simple. Well it came with the “it works on my machine” seal of approval and indeed it worked on my machine, but not on others.  It turns out there is a difference between

Continue reading »

Double Postback in ASP .Net

One of the things that I’ve seen in a number of different ASP .Net apps is a double post back. Once you get it on a page it seems to be almost impossible to work around. You’ll get everything from optimistic concurrency exceptions, double orders, repeated emails – all kinds of rubbish. It started happening

Continue reading »

NeverNull – because we can’t extend the ?? operator

This morning @JeffHandley tweeted this http://www.forkcan.com/viewcode/277/Null-Dot-Operator-Extension-Method essentially the idea is that you can call your code and apply default options. I kinda like the idea, but I wasn’t so convinced of the name he chose for the name of his extension method _ it kinda looks like an operator, but really isn’t and you have

Continue reading »

Simplifying Session Wrapping Properties using Expression<Func>

I’m not a big fan of using session, but sometimes there isn’t a sensible alternative. In that case I always wrap the session object in a property. In the past I’ve failed to come up with a satisfactory session variable naming convention. With that I’ve always hated using strings for session names. Each solution basically

Continue reading »

Extension method for validating entities.

I’ve written this a couple of times this morning:

if (string.IsNullOrWhiteSpace(Name))
{
errors.Add(new KeyValuePair(“Name”, “Name must contain some text”));
}

if ((Name ?? “”).Length > 50)
{
errors.Add(new KeyValuePair(“Name”, “Name cannot be more that 50 characters long”));
}
I couldn’t help but feel that if I had to write this more than about twice I would go nuts, never mind the obvious maintenance problems.

Continue reading »