Is there an easy way to determine if a the value of an Entity Property is still set to the default value?
I have found in the past that it is often useful to have a class with publicly accessible static members containing the default value for each System Type. This way it is easy to check if a value is still default by comparing it to this value.
By adding the following code to the Custom_TypeDefaultValueTemplate Template, this can easily be achieved.
public static System.String NullString = String.Empty;
public static System.Byte NullByte = (byte)0;
public static System.Int32 NullInt32 = (int)0;
public static System.Int16 NullInt16 = (short)0;
public static System.Int64 NullInt64 = (long)0;
public static System.DateTime NullDateTime = DateTime.MinValue;
public static System.Decimal NullDecimal = 0.0M;
public static System.Double NullDouble = 0.0;
public static System.Single NullSingle = 0.0f;
public static System.Boolean NullBoolean = false;
public static System.Byte[] NullByteArray = new byte[0];
public static System.Guid NullGuid = Guid.Empty;
public static System.Object NullObject = new object();
Then to check if a value is default, the following code is all that is needed:
if(Entity.StringProperty.equals(TypeDefaultValue.NullString)){...
Any comments on this welcome.