Turning off default PK Clustered index


Author
Message
StrataFrame Team
S
StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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 Smile

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 Wink  Obviously, you're way will work, but the slowness of reflection was the exact reason that we created those descriptors.

Paul Chase
Paul Chase
Advanced StrataFrame User (598 reputation)Advanced StrataFrame User (598 reputation)Advanced StrataFrame User (598 reputation)Advanced StrataFrame User (598 reputation)Advanced StrataFrame User (598 reputation)Advanced StrataFrame User (598 reputation)Advanced StrataFrame User (598 reputation)Advanced StrataFrame User (598 reputation)Advanced StrataFrame User (598 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Awesome Ben I knew the property descriptor was there but didn't think to use it! Smile

Thanks

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (964 reputation)Advanced StrataFrame User (964 reputation)Advanced StrataFrame User (964 reputation)Advanced StrataFrame User (964 reputation)Advanced StrataFrame User (964 reputation)Advanced StrataFrame User (964 reputation)Advanced StrataFrame User (964 reputation)Advanced StrataFrame User (964 reputation)Advanced StrataFrame User (964 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
You guys are terrific. I'm really glad I asked about this. Clustered indexes here I come BigGrin
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search