IdeaBlade DevForce 2010 Help Reference
DefaultValueFunction Property
See Also  Example Send Feedback
IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntityMetadata Class : DefaultValueFunction Property



Use to override how DevForce sets the default value for a data entity property.

Syntax

Visual Basic (Declaration) 
Public Shared Property DefaultValueFunction As Func(Of Type,Object)
Visual Basic (Usage)Copy Code
Dim value As Func(Of Type,Object)
 
EntityMetadata.DefaultValueFunction = value
 
value = EntityMetadata.DefaultValueFunction
C# 
public static Func<Type,object> DefaultValueFunction {get; set;}
C++/CLI 
public:
static property Func<Type^,Object^>^ DefaultValueFunction {
   Func<Type^,Object^>^ get();
   void set (    Func<Type^,Object^>^ value);
}

Example

C#Copy Code
// 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);
};

Remarks

Use the DefaultValueFunction to override how DevForce determines the default value for a IdeaBlade.EntityModel.DataEntityProperty. If you do not specify an override, the value returned by DevForceDefaultValueFunction is used. Note that the override is not on an Entity basis - the override will apply to all Entity types. For example, you may want to override the default DateTime value with your own code - this override would apply to DateTime data entity properties in all Entity types.

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.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.