Assign this attribute to a data type property to enforce a default value for the property on newly created instanced of your data type.
You specify a serialized C1 Function - this C1 Function will be executed and the result will be written to this property.
Namespace: Composite.DataAssembly: Composite (in Composite.dll) Version: 5.3.6135.33083
Syntax
C# |
---|
public sealed class FunctionBasedNewInstanceDefaultFieldValueAttribute : NewInstanceDefaultFieldValueAttribute |
Visual Basic |
---|
Public NotInheritable Class FunctionBasedNewInstanceDefaultFieldValueAttribute _ Inherits NewInstanceDefaultFieldValueAttribute |
Visual C++ |
---|
public ref class FunctionBasedNewInstanceDefaultFieldValueAttribute sealed : public NewInstanceDefaultFieldValueAttribute |
Examples
This sample shows how to use the FunctionBasedNewInstanceDefaultFieldValue attribute.
Here the current date and time is set on the Created property through the use of the C1 Function Composite.Utils.Date.Now.
CopyC#

// data interface attributes ... interface IMyDataType : IData { [FunctionBasedNewInstanceDefaultFieldValue(@"<f:function name='Composite.Utils.Date.Now' xmlns:f='http://www.composite.net/ns/function/1.0' />")] [StoreFieldType(PhysicalStoreFieldType.DateTime)] [ImmutableFieldId("{D75EA67F-AD14-4BAB-8547-6D87002809F1}")] DateTime Created { get; set; } // more data properties ... }
Inheritance Hierarchy
System..::..Object
System..::..Attribute
NewInstanceDefaultFieldValueAttribute
Composite.Data..::..FunctionBasedNewInstanceDefaultFieldValueAttribute
System..::..Attribute
NewInstanceDefaultFieldValueAttribute
Composite.Data..::..FunctionBasedNewInstanceDefaultFieldValueAttribute