IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntityMetadata Class : DefaultValueFunction Property |
'Declaration
Public Shared Property DefaultValueFunction As Func(Of Type,Object)
'Usage
Dim value As Func(Of Type,Object) EntityMetadata.DefaultValueFunction = value value = EntityMetadata.DefaultValueFunction
public static Func<Type,object> DefaultValueFunction {get; set;}
You must set your override for the DefaultValueFunction as early as possible in your processing. The DataEntityProperties of your entities are static fields of these entities, and will be initialized as the entity types are referenced.
// To override the default value used for some property types. // Here, DateTime properties default to Today with an Unspecified Kind, and // longs to -1; all other types will use the DevForce-provided default value. EntityMetadata.DefaultValueFunction = (t) => { if (t == typeof(DateTime)) { return DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Unspecified); } if (t == typeof(long)) { return -1L; } return EntityMetadata.DevForceDefaultValueFunction(t); };
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2