Just a quick not on how to pass and render HtmlAttributes in a helper: public HtmlString Add(YourObject yourObject, object htmlAttributes = null) { var attributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); //process you markup etc. attributes.ToHtmlAttributes() } public static class RouteValueDictionaryExtensions { public static…Continue Reading →
Just a little note to explain how to mark up an EF class that has multiple related properties of the same type. You have to set the ForeignKey attribute to the virtual property you want related. Add-migration will add cascadeDelete…Continue Reading →
When using a CE database for constructing MVC 3 Controllers you get the following error if using providerName=”System.Data.SqlServerCe.4.0″. “Unable to retreive metadata for ‘X.Y.Z’. Using the same DbCompiledModel to create contexts against different types of database servers is not supported….Continue Reading →
When writing unit test to check events have fired you need to add an extra delegate that also gets called back. I was refactoring my PropertyChanged system and came up with the following: List<string> EventTracking = new List<string>(); [TestInitialize] public void Init()…Continue Reading →
extension method to compare generics for default public static bool IsDefaultOrNull(this T value) { return EqualityComparer.Default.Equals(value, default(T)); }
I’ve got a simple class I use in a framework so the business objects can use different distinct identifiers (DB int, guid, key etc). public class Identifier<t> { private T _value; public Identifier(){ } public Identifier(T value) { Value…Continue Reading →