Yep, Paul is right... Just override the OnSetDefaultValues() method and set your PK in there by calling whatever method you create to get the sequential guid from the date. Dim LoPkField As Reflection.PropertyInfo = Me.GetType.GetProperty(Me.PrimaryKeyField)
There is a faster way to do that, Paul
Imports MicroFour.StrataFrame.Business
...
Protected Overrides Sub OnSetDefaultValues()
MyBase.OnSetDefaultValues()
'-- Set Value for GUID PK
'-- Get a reference to the property descriptor (which doesn't use reflection)
Dim desc As FieldPropertyDescriptor = Me.GetPropertyDescriptor(Me.PrimaryKeyField)
'-- If the PK is a Guid Generate a Sequential GUID to prevent Index fragmentation
If desc.PropertyType Is GetType(Guid) Then
desc.SetValue(Me, Common.NewSeqID())
End If
End Sub
This way uses the FieldPropertyDescriptors created in the partial class... which are much faster than using reflection Obviously, you're way will work, but the slowness of reflection was the exact reason that we created those descriptors.